pub fn expected_with<T>(
val: T,
description_func: fn(&T) -> String,
) -> Expected<T>
Expand description
Creates a new Expected wrapper. You should provide your own function to represent value as String. Can be used if you need custom description or value doesn’t implement Display trait
§Examples
Basic usage:
use easy_assert::{expected_with};
fn my_description(value: &i32) -> String {
format!("My own description for value {}", value)
}
let expected = expected_with(1, my_description);
Test usage:
use easy_assert::{actual_with, expected_with};
use easy_assert::num_assertions::NumericAssert;
fn my_description(value: &i32) -> String {
format!("My own description for value {}", value)
}
NumericAssert::assert_that(actual_with(1, my_description))
.is_equal().to(expected_with(1, my_description));