use std::{
collections::{BTreeSet, btree_set::IntoIter},
fmt::Display,
sync::Mutex,
};
static HINTS: Mutex<BTreeSet<Hint>> = Mutex::new(BTreeSet::new());
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Hint(String);
impl Display for Hint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<String> for Hint {
fn from(value: String) -> Self {
Self(value)
}
}
impl From<&str> for Hint {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}
pub fn add_hint(hint: Hint) {
HINTS.lock().unwrap().insert(hint);
}
#[macro_export]
macro_rules! hint {
($($arg:tt)*) => {{
$crate::add_hint(format!($($arg)*).into());
}};
}
pub fn get_hints() -> IntoIter<Hint> {
HINTS.lock().unwrap().clone().into_iter()
}