use serde::{Deserialize, Serialize};
use std::fmt::Display;
use std::path::PathBuf;
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Ignored {
#[serde(default = "default_ignored")]
pub file: PathBuf,
#[serde(default = "default_comment")]
pub comment: char,
}
impl Display for Ignored {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Ignored {{ file: {}, comment: '{}' }}",
self.file.display(),
self.comment
)
}
}
impl Default for Ignored {
fn default() -> Self {
Self {
file: default_ignored(),
comment: default_comment(),
}
}
}
const fn default_comment() -> char {
'#'
}
fn default_ignored() -> PathBuf {
PathBuf::from(concat!(".", env!("CARGO_BIN_NAME"), "-ignore"))
}