use thiserror::Error;
#[derive(Error, Debug)]
#[error("{}", self.display_message())]
pub struct Unimplemented {
feature: Option<String>,
planned: bool,
}
impl Default for Unimplemented {
fn default() -> Self {
Self::new()
}
}
impl Unimplemented {
pub fn new() -> Self {
Self {
feature: None,
planned: false,
}
}
pub fn feature<S: Into<String>>(feature: S) -> Self {
Self {
feature: Some(feature.into()),
planned: false,
}
}
pub fn planned_feature<S: Into<String>>(feature: S) -> Self {
Self {
feature: Some(feature.into()),
planned: true,
}
}
pub fn planned_anonymous_feature() -> Self {
Self {
feature: None,
planned: true,
}
}
fn display_message(&self) -> String {
match (&self.feature, self.planned) {
(Some(feature), true) => format!("'{feature}' is planned but not yet implemented"),
(Some(feature), false) => format!("'{feature}' is not yet planned"),
(None, true) => "This feature is planned but not yet implemented".to_string(),
(None, false) => "This feature is not yet planned".to_string(),
}
}
}