use core::fmt::Debug;
use core::marker::PhantomData;
use super::Neu;
use crate::MayDebug;
pub struct Always<T>(PhantomData<T>);
impl<T: MayDebug> core::ops::Not for Always<T> {
type Output = crate::neu::Not<Self, T>;
fn not(self) -> Self::Output {
crate::neu::not(self)
}
}
impl<T> Debug for Always<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("Always").field(&self.0).finish()
}
}
impl<T> Default for Always<T> {
fn default() -> Self {
Self(Default::default())
}
}
impl<T> Clone for Always<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Always<T> {}
impl<T> Always<T> {
pub const fn new() -> Self {
Self(PhantomData)
}
}
impl<T: MayDebug> Neu<T> for Always<T> {
#[inline(always)]
fn is_match(&self, _other: &T) -> bool {
crate::trace_retval!("Always", _other, true)
}
}
pub const fn always<T: MayDebug>() -> Always<T> {
Always(PhantomData)
}
pub struct Never<T>(PhantomData<T>);
impl<T: MayDebug> core::ops::Not for Never<T> {
type Output = crate::neu::Not<Self, T>;
fn not(self) -> Self::Output {
crate::neu::not(self)
}
}
impl<T> Debug for Never<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("Never").field(&self.0).finish()
}
}
impl<T> Default for Never<T> {
fn default() -> Self {
Self(Default::default())
}
}
impl<T> Clone for Never<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Never<T> {}
impl<T> Never<T> {
pub const fn new() -> Self {
Self(PhantomData)
}
}
impl<T: MayDebug> Neu<T> for Never<T> {
#[inline(always)]
fn is_match(&self, _other: &T) -> bool {
crate::trace_retval!("Never", _other, false)
}
}
pub const fn never<T: MayDebug>() -> Never<T> {
Never(PhantomData)
}