pub struct Assert<A, B>(_);
Expand description
Implementations
sourceimpl<A, B> Assert<A, B> where
A: TStrEq<B>,
impl<A, B> Assert<A, B> where
A: TStrEq<B>,
sourcepub const EQUAL: EqualityProof<A, B> = {
["Expected the type parameters to be equal"][A::NE as usize];
EqualityProof(PhantomData)
}
Available on crate feature cmp_traits
only.
pub const EQUAL: EqualityProof<A, B> = { ["Expected the type parameters to be equal"][A::NE as usize]; EqualityProof(PhantomData) }
cmp_traits
only.Asserts that the A
and B
type-level strings compare equal.
sourceimpl<A, B> Assert<A, B> where
A: TStrEq<B>,
impl<A, B> Assert<A, B> where
A: TStrEq<B>,
sourcepub const NOT_EQUAL: InequalityProof<A, B> = {
["Expected the type parameters to not be equal"][A::EQ as usize];
InequalityProof(PhantomData)
}
Available on crate feature cmp_traits
only.
pub const NOT_EQUAL: InequalityProof<A, B> = { ["Expected the type parameters to not be equal"][A::EQ as usize]; InequalityProof(PhantomData) }
cmp_traits
only.Asserts that the A
and B
type-level strings compare not equal.
Example
This uses types from the for_examples
module,
which can be seen in the docs with the “for_examples” feature.
use tstr::for_examples::Foo;
use tstr::{Assert, ts};
use std::ops::Index;
let this = Foo::new(3, 5, "8");
assert_eq!(this.get_two(ts!(bar), ts!(qux), Assert::NOT_EQUAL), (&3, &"8"))
The same method call errors when we try to get two references to the same field.
ⓘ
use tstr::for_examples::Foo;
use tstr::{Assert, ts};
use std::ops::Index;
let this = Foo::new(3, 5, "8");
assert_eq!(this.get_two(ts!(bar), ts!(bar), Assert::NOT_EQUAL), (&3, &3))
Truncated error:
error[E0080]: erroneous constant used
--> src/asserts.rs:55:45
|
11 | assert_eq!(this.get_two(ts!(bar), ts!(bar), Assert::NOT_EQUAL), (&3, &3))
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
Auto Trait Implementations
impl<A, B> RefUnwindSafe for Assert<A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Assert<A, B> where
A: Send,
B: Send,
impl<A, B> Sync for Assert<A, B> where
A: Sync,
B: Sync,
impl<A, B> Unpin for Assert<A, B> where
A: Unpin,
B: Unpin,
impl<A, B> UnwindSafe for Assert<A, B> where
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more