tstr/macros/cmp_macros.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
/// For comparing [`TStr`] types for equality, using [`TStrEq::EQ`].
///
/// # Example
///
/// ```rust
/// use tstr::{TS, tstr_eq};
///
/// assert!( tstr_eq!(TS!("foo"), TS!("foo")));
/// assert!(!tstr_eq!(TS!("foo"), TS!("bar")));
///
/// type Foo = TS!("foo");
/// type Bar = TS!("bar");
///
/// assert!( tstr_eq!(Foo, Foo));
/// assert!(!tstr_eq!(Foo, Bar));
/// ```
///
/// [`TStrEq::EQ`]: ./trait.TStrEq.html#associatedconstant.EQ
/// [`TStr`]: ./struct.TStr.html
///
#[macro_export]
#[cfg(feature = "cmp_traits")]
macro_rules! tstr_eq {
($left:ty, $right:ty $(,)*) => {
<$left as $crate::TStrEq<$right>>::EQ
};
}
/// For comparing [`TStr`] types for inequality, using [`TStrEq::NE`]
///
/// # Example
///
/// ```rust
/// use tstr::{TS, tstr_ne};
///
/// assert!(!tstr_ne!(TS!("foo"), TS!("foo")));
/// assert!( tstr_ne!(TS!("foo"), TS!("bar")));
///
/// type Foo = TS!("foo");
/// type Bar = TS!("bar");
///
/// assert!(!tstr_ne!(Foo, Foo));
/// assert!( tstr_ne!(Foo, Bar));
/// ```
///
/// [`TStrEq::NE`]: ./trait.TStrEq.html#associatedconstant.NE
/// [`TStr`]: ./struct.TStr.html
#[macro_export]
#[cfg(feature = "cmp_traits")]
macro_rules! tstr_ne {
($left:ty, $right:ty $(,)*) => {
<$left as $crate::TStrEq<$right>>::NE
};
}
/// For comparing [`TStr`] types for ordering, using [`TStrOrd::CMP`]
///
/// # Example
///
/// ```rust
/// use tstr::{TS, tstr_cmp};
///
/// use std::cmp::Ordering;
///
/// type Aaa = TS!(Aaa);
/// type Bbb = TS!(Bbb);
/// type Ccc = TS!(Ccc);
///
/// assert_eq!(tstr_cmp!(Bbb, Ccc), Ordering::Less);
/// assert_eq!(tstr_cmp!(Bbb, Bbb), Ordering::Equal);
/// assert_eq!(tstr_cmp!(Bbb, Aaa), Ordering::Greater);
/// ```
///
/// [`TStrOrd::CMP`]: ./trait.TStrOrd.html#associatedconstant.CMP
/// [`TStr`]: ./struct.TStr.html
#[cfg(feature = "const_generics")]
#[macro_export]
#[cfg(feature = "cmp_traits")]
macro_rules! tstr_cmp {
($left:ty, $right:ty $(,)*) => {
<$left as $crate::TStrOrd<$right>>::CMP
};
}