pub struct Assert<A, B>(_);
Expand description

For asserting the (in)equality of two type-level strings.

Warning

From testing the associated constants from this type, these assertions might not be evaluated in functions that aren’t reachable by public functions.

Examples

For examples, you can look at each associated constant below.

Implementations

Available on crate feature cmp_traits only.

Asserts that the A and B type-level strings compare equal.

Available on crate feature 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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.