use crate::kind::*;
use crate::ops::multiset::Insert;
pub trait Empty {
fn empty() -> Self;
}
pub trait Singleton : Collection {
fn singleton(value: Self::Item) -> Self;
}
macro_rules! singleton_impl
{
( $( $keyword:tt ),*) =>
{
impl<R> Singleton for R where
R: Empty + Insert + Collection + SequenceKind
{
$($keyword)* fn singleton(value: Self::Item) -> Self {
let mut collection = R::empty();
collection.insert(value);
collection
}
}
}
}
#[cfg(feature = "nightly")]
singleton_impl!(default);
#[cfg(not(feature = "nightly"))]
singleton_impl!();