mod severity;
use crate::issue::Issue;
use std::time::Instant;
use core::fmt::{
Display,
Formatter,
Result as Format
};
pub use severity::Severity;
pub struct Problem<Object: Into<Issue>> {
pub chain: Vec<&'static str>,
pub at: Instant,
pub object: Object,
pub severity: Severity
}
impl Display for Problem<Issue> {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Format {write!(
formatter,
"@ {}\n{:?}: {}{}",
self.chain.iter().rev().map(|node| *node).collect::<Vec<&'static str>>().join(" > "),
<&Severity as Into<&'static str>>::into(&self.severity),
self.object.name,
if let Some(description) = &self.object.description {format!("\n {}", description)} else {String::new()}
)}
}