AssertSameAs

Trait AssertSameAs 

Source
pub trait AssertSameAs<E> {
    // Required methods
    fn is_same_as(self, expected: E) -> Self;
    fn is_not_same_as(self, expected: E) -> Self;
}
Expand description

Assert whether two values are of the same type and have the same value.

These assertions are implemented for all types that implement PartialEq.

§Examples

use asserting::prelude::*;

let subject = String::from("adipiscing liber esse anim");
assert_that!(subject).is_same_as("adipiscing liber esse anim".to_string());

let subject = "ea eu exercitation eu";
assert_that!(subject).is_not_same_as("Ea eu exercitation");

assert_that!(42).is_same_as(42);
assert_that!(41).is_not_same_as(42);

Required Methods§

Source

fn is_same_as(self, expected: E) -> Self

Verifies that the subject is of the same type and has the same value as some other value.

§Examples
use asserting::prelude::*;

let subject = String::from("adipiscing liber esse anim");
assert_that!(subject).is_same_as("adipiscing liber esse anim".to_string());

assert_that!(42).is_same_as(42);
Source

fn is_not_same_as(self, expected: E) -> Self

Verifies that the subject is of the same type but has a different value as some other value.

§Examples
use asserting::prelude::*;

let subject = "ea eu exercitation eu";
assert_that!(subject).is_not_same_as("Ea eu exercitation");

assert_that!(41).is_not_same_as(42);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, R> AssertSameAs<S> for Spec<'_, S, R>