use std::borrow::Borrow;
use std::hash::Hash;
use lazy_static::lazy_static;
use crate::interner::Interner;
use crate::Tok;
lazy_static! {
static ref SINGLETON: Interner = Interner::new();
}
#[must_use]
pub fn i<Q>(q: &Q) -> Tok<Q::Owned>
where
Q: ?Sized + Eq + Hash + ToOwned,
Q::Owned: 'static + Eq + Hash + Clone + Borrow<Q> + Send + Sync,
{
SINGLETON.i(q)
}
#[must_use]
pub fn ev<'a, T: 'static + Eq + Hash + Clone + Send + Sync>(
s: impl IntoIterator<Item = &'a Tok<T>>,
) -> Vec<T> {
s.into_iter().map(|t| (**t).clone()).collect()
}
pub fn sweep_t<T: Eq + Hash + Clone + Send + Sync + 'static>() -> usize {
SINGLETON.sweep_t::<T>()
}
pub fn sweep() -> usize { SINGLETON.sweep() }
pub fn iv<T: 'static + Eq + Hash + Clone + Sync + Send>(
s: impl IntoIterator<Item = T>,
) -> Tok<Vec<Tok<T>>> {
SINGLETON.iv(s)
}
pub fn ibv<'a, Q>(s: impl IntoIterator<Item = &'a Q>) -> Tok<Vec<Tok<Q::Owned>>>
where
Q: ?Sized + Eq + Hash + ToOwned + 'a,
Q::Owned: Eq + Hash + Clone + Send + Sync,
{
SINGLETON.ibv(s)
}