ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.96k stars 274 forks source link

ParseColorError is not public #1085

Closed orhun closed 2 months ago

orhun commented 2 months ago

Description

I have a custom error implementation via thiserror in my project. I would like to have an error variant that corresponds to ParseColorError in Ratatui, but I am unable to use that type since it is private.

To Reproduce

use ratatui::style::Color;
use std::str::FromStr;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    /// Error that may occur while parsing colors.
    #[error("Parse color error: `{0:?}`")]
    ParseColor(ratatui::style::color::ParseColorError),
}

fn main() -> Result<(), AppError> {
    let color = Color::from_str("#000000")?;

    Ok(())
}
9  |     ParseColor(ratatui::style::color::ParseColorError),
   |                                ^^^^^  --------------- struct `ParseColorError` is not publicly re-exported
   |                                |
   |                                private module

Proposal

Make ParseColorError public, either via exposing it from ratatui::style::color::ParseColorError or ratatui::style::ParseColorError. I think latter makes more sense since color module is private.