pub struct Spec<'a, S, R> { /* private fields */ }Expand description
Data of an actual assertion.
It holds the data needed to execute an assertion such as the subject, the name of the subject or expression, an optional description of the current assertion, and the location of the assertion in the source code respectively test code.
It also holds the concrete FailingStrategy on how to behave in case
an assertion fails.
In case of the CollectFailures failing strategy, the AssertFailures
are collected in this struct.
Implementations§
Source§impl<S, R> Spec<'_, S, R>
impl<S, R> Spec<'_, S, R>
Sourcepub fn expression(&self) -> &Expression<'_>
pub fn expression(&self) -> &Expression<'_>
Returns the expression (or subject name) if one has been set.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the description or the assertion if it has been set.
Sourcepub const fn diff_format(&self) -> &DiffFormat
pub const fn diff_format(&self) -> &DiffFormat
Returns the diff format used with this assertion.
Sourcepub fn failing_strategy(&self) -> &R
pub fn failing_strategy(&self) -> &R
Returns the failing strategy used in case an assertion fails.
Source§impl<'a, S, R> Spec<'a, S, R>
impl<'a, S, R> Spec<'a, S, R>
Sourcepub fn new(subject: S, failing_strategy: R) -> Self
pub fn new(subject: S, failing_strategy: R) -> Self
Constructs a new Spec for the given subject and with the specified
failing strategy.
The diff format is set to “no highlighting”. Failure messages will not highlight differences between the actual and the expected value.
Sourcepub fn named(self, subject_name: impl Into<Cow<'a, str>>) -> Self
pub fn named(self, subject_name: impl Into<Cow<'a, str>>) -> Self
Sets the subject name or expression for this assertion.
Sourcepub fn described_as(self, description: impl Into<Cow<'a, str>>) -> Self
pub fn described_as(self, description: impl Into<Cow<'a, str>>) -> Self
Sets a custom description about what is being asserted.
Sourcepub const fn located_at(self, location: Location<'a>) -> Self
pub const fn located_at(self, location: Location<'a>) -> Self
Sets the location of the assertion in the source code respectively test code.
Sourcepub const fn with_diff_format(self, diff_format: DiffFormat) -> Self
pub const fn with_diff_format(self, diff_format: DiffFormat) -> Self
Sets the diff format used to highlight differences between the actual value and the expected value.
Note: This method must be called before an assertion method is called to affect the failure message of the assertion as failure messages are formatted immediately when an assertion is executed.
Sourcepub fn with_configured_diff_format(self) -> Self
Available on crate feature colored only.
pub fn with_configured_diff_format(self) -> Self
colored only.Sets the diff format used to highlight differences between the actual value and the expected value according to the configured mode.
The mode is configured via environment variables as described in the module colored.
Sourcepub fn using_recursive_comparison(self) -> RecursiveComparison<'a, S, R>
Available on crate feature recursive only.
pub fn using_recursive_comparison(self) -> RecursiveComparison<'a, S, R>
recursive only.Switches this Spec to the “field-by-field recursive comparison
mode”.
It returns a RecursiveComparison which is a specialized Spec that
provides extra configuration options for the recursive comparison and
the special is_equivalent_to/is_not_equivalent_to assertions of the
AssertEquivalence trait.
See the documentation of the recursive_comparison module for details
about field-by-field recursive comparison.
Sourcepub fn extracting_ref<F, B, U>(
self,
property_name: impl Into<Cow<'a, str>>,
extract: F,
) -> DerivedSpec<'a, Self, U>
pub fn extracting_ref<F, B, U>( self, property_name: impl Into<Cow<'a, str>>, extract: F, ) -> DerivedSpec<'a, Self, U>
Extracts a property from the current subject.
The extracting closure gets a reference to the current subject as an argument and should return a reference to the extracted property. The given property name is used in failure reports for referencing the property for which an assertion fails.
Use this method if you want to extract multiple properties from the
same subject for individual assertions on each of these properties.
To extract another property from the original subject, call the and
method to switch back to the original subject before calling
extracting_ref for the other property.
The expression for failure reports is built from the expression of the
original subject, a dot as a separator, and the given property name.
The resulting expression is equal to
format!("{original_expression}.{property_name}").
If you do not like the default built expression, it can be overwritten
by calling the named method after the call to the extract method.
§Arguments
property_name- A name describing the extracted property used for referencing this property in failure reports.extract- A closure that returns a reference to the property to be extracted.
§Examples
use asserting::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq)]
enum Gender {
Male,
Female,
NonBinary,
PreferNotToSay,
}
struct Person {
name: String,
age: u8,
gender: Gender,
}
impl Person {
fn name(&self) -> &str {
&self.name
}
}
let my_friend = Person {
name: "Silvia".into(),
age: 27,
gender: Gender::Female,
};
assert_that!(my_friend)
.extracting_ref("name", Person::name)
.is_equal_to("Silvia")
.and()
.extracting_ref("age", |p| &p.age)
.is_at_least(18)
.and()
.extracting_ref("gender", |p| &p.gender)
.is_equal_to(Gender::Female);Sourcepub fn extracting<F, U>(
self,
property_name: impl Into<Cow<'a, str>>,
extract: F,
) -> Spec<'a, U, R>where
F: FnOnce(S) -> U,
pub fn extracting<F, U>(
self,
property_name: impl Into<Cow<'a, str>>,
extract: F,
) -> Spec<'a, U, R>where
F: FnOnce(S) -> U,
Maps the current subject to some other value.
It takes a closure that maps the current subject to a new subject and
returns a new Spec with the value returned by the closure as the new
subject. The new subject may have a different type than the original
subject. All other data like description, location, and diff format are
taken over from this Spec into the returned Spec.
This method is useful when having a custom type, and one specific
property of this type shall be asserted only. If you want to assert
multiple properties of the same subject, use the extracting_ref
method instead.
This method is similar to the mapping method. In contrast to
mapping, this method does not copy the subject’s name
(or expression) but builds a new expression from the given
property_name and the expression of the original subject. The
idea is that the “extracted” property is most likely a different subject
than the original one.
The expression for failure reports is built from the expression of the
original subject, a dot as a separator, and the given property name.
The resulting expression is equal to
format!("{original_expression}.{property_name}").
If you do not like the default built expression, it can be overwritten
by calling the named method after the call to the extract method.
§Arguments
property_name- A name describing the extracted property used for referencing this property in failure reports.extract- A closure that returns the property to be extracted.
§Example
use asserting::prelude::*;
struct MyStruct {
important_property: String,
other_property: f64,
}
let some_thing = MyStruct {
important_property: "imperdiet aliqua zzril eiusmod".into(),
other_property: 99.9,
};
assert_that!(some_thing)
.extracting("important_property", |s| s.important_property)
.is_equal_to("imperdiet aliqua zzril eiusmod");In this example the resulting expression used in failure reports to
reference the asserted subject is "some_thing.important_property".
To overwrite the default built expression for failure reports, we can
call the named method, like so:
assert_that!(some_thing)
.extracting("important_property", |s| s.important_property)
.is_equal_to("imperdiet aliqua zzril eiusmod")
.named("my_struct's important property");Sourcepub fn mapping<F, U>(self, map: F) -> Spec<'a, U, R>where
F: FnOnce(S) -> U,
pub fn mapping<F, U>(self, map: F) -> Spec<'a, U, R>where
F: FnOnce(S) -> U,
Maps the current subject to some other value.
It takes a closure that maps the current subject to a new subject and
returns a new Spec with the value returned by the closure as the new
subject. The new subject may have a different type than the original
subject. All other data like expression, description, and location are
taken over from this Spec into the returned Spec.
This method is useful if some type does not implement a trait required for an assertion.
Spec also provides the extracting() method,
which is similar to this method. In contrast to this method,
extracting() does not copy the subject’s name
(or expression) but builds a new expression from the expression of the
original subject and the given property name.
§Example
use asserting::prelude::*;
struct Point {
x: i64,
y: i64,
}
let target = Point { x: 12, y: -64 };
assert_that!(target).mapping(|s| (s.x, s.y)).is_equal_to((12, -64));The custom type Point does not implement the PartialEq trait nor
the Debug trait, which are both required for an is_equal_to
assertion. So we map the subject of the type Point to a tuple of its
fields.
Trait Implementations§
Source§impl<R> AssertBoolean for Spec<'_, bool, R>where
R: FailingStrategy,
impl<R> AssertBoolean for Spec<'_, bool, R>where
R: FailingStrategy,
Source§impl<R> AssertChar for Spec<'_, char, R>where
R: FailingStrategy,
impl<R> AssertChar for Spec<'_, char, R>where
R: FailingStrategy,
Source§fn is_lowercase(self) -> Self
fn is_lowercase(self) -> Self
Source§fn is_uppercase(self) -> Self
fn is_uppercase(self) -> Self
Source§fn is_alphabetic(self) -> Self
fn is_alphabetic(self) -> Self
Source§fn is_alphanumeric(self) -> Self
fn is_alphanumeric(self) -> Self
Source§fn is_control_char(self) -> Self
fn is_control_char(self) -> Self
Source§fn is_digit(self, radix: u32) -> Self
fn is_digit(self, radix: u32) -> Self
Source§fn is_whitespace(self) -> Self
fn is_whitespace(self) -> Self
Source§impl<R> AssertChar for Spec<'_, &char, R>where
R: FailingStrategy,
impl<R> AssertChar for Spec<'_, &char, R>where
R: FailingStrategy,
Source§fn is_lowercase(self) -> Self
fn is_lowercase(self) -> Self
Source§fn is_uppercase(self) -> Self
fn is_uppercase(self) -> Self
Source§fn is_alphabetic(self) -> Self
fn is_alphabetic(self) -> Self
Source§fn is_alphanumeric(self) -> Self
fn is_alphanumeric(self) -> Self
Source§fn is_control_char(self) -> Self
fn is_control_char(self) -> Self
Source§fn is_digit(self, radix: u32) -> Self
fn is_digit(self, radix: u32) -> Self
Source§fn is_whitespace(self) -> Self
fn is_whitespace(self) -> Self
Source§impl<'a, S, R> AssertCodePanics for Spec<'a, Code<S>, R>where
S: FnOnce(),
R: FailingStrategy,
Available on crate feature panic only.
impl<'a, S, R> AssertCodePanics for Spec<'a, Code<S>, R>where
S: FnOnce(),
R: FailingStrategy,
panic only.Source§type Mapped = Spec<'a, (), R>
type Mapped = Spec<'a, (), R>
Source§fn does_not_panic(self) -> Self::Mapped
fn does_not_panic(self) -> Self::Mapped
Source§impl<'a, S, R> AssertDebugString for Spec<'a, S, R>where
S: Debug,
R: FailingStrategy,
impl<'a, S, R> AssertDebugString for Spec<'a, S, R>where
S: Debug,
R: FailingStrategy,
Source§type DebugString = Spec<'a, String, R>
type DebugString = Spec<'a, String, R>
Source§fn debug_string(self) -> Self::DebugString
fn debug_string(self) -> Self::DebugString
Source§impl<S, R> AssertDecimalNumber for Spec<'_, S, R>
impl<S, R> AssertDecimalNumber for Spec<'_, S, R>
Source§fn has_scale_of(self, expected_scale: i64) -> Self
fn has_scale_of(self, expected_scale: i64) -> Self
Source§fn has_precision_of(self, expected_precision: u64) -> Self
fn has_precision_of(self, expected_precision: u64) -> Self
Source§fn is_integer(self) -> Self
fn is_integer(self) -> Self
Source§impl<'a, S, R> AssertDisplayString for Spec<'a, S, R>where
S: Display,
R: FailingStrategy,
impl<'a, S, R> AssertDisplayString for Spec<'a, S, R>where
S: Display,
R: FailingStrategy,
Source§type DisplayString = Spec<'a, String, R>
type DisplayString = Spec<'a, String, R>
Source§fn display_string(self) -> Self::DisplayString
fn display_string(self) -> Self::DisplayString
Source§impl<'a, I, R> AssertElements<'a, I> for Spec<'a, I, R>where
I: IntoIterator,
impl<'a, I, R> AssertElements<'a, I> for Spec<'a, I, R>where
I: IntoIterator,
Source§fn each_element<A, B>(self, assert: A) -> Self::Output
fn each_element<A, B>(self, assert: A) -> Self::Output
Source§fn any_element<A, B>(self, assert: A) -> Self::Output
fn any_element<A, B>(self, assert: A) -> Self::Output
Source§impl<S, R> AssertEmptiness for Spec<'_, S, R>
impl<S, R> AssertEmptiness for Spec<'_, S, R>
Source§impl<S, E, R> AssertEquality<E> for Spec<'_, S, R>
impl<S, E, R> AssertEquality<E> for Spec<'_, S, R>
Source§fn is_equal_to(self, expected: E) -> Self
fn is_equal_to(self, expected: E) -> Self
Source§fn is_not_equal_to(self, expected: E) -> Self
fn is_not_equal_to(self, expected: E) -> Self
Source§impl<'a, S, R> AssertErrorHasSource for Spec<'a, S, R>where
S: Error,
R: FailingStrategy,
impl<'a, S, R> AssertErrorHasSource for Spec<'a, S, R>where
S: Error,
R: FailingStrategy,
Source§type SourceMessage = Spec<'a, Option<String>, R>
type SourceMessage = Spec<'a, Option<String>, R>
Source§fn has_no_source(self) -> Self
fn has_no_source(self) -> Self
Source§fn has_source(self) -> Self
fn has_source(self) -> Self
Source§fn has_source_message(
self,
expected_source_message: impl Into<String>,
) -> Self::SourceMessage
fn has_source_message( self, expected_source_message: impl Into<String>, ) -> Self::SourceMessage
Source§impl<'a, S, T, R> AssertFilteredElements<T> for Spec<'a, S, R>
impl<'a, S, T, R> AssertFilteredElements<T> for Spec<'a, S, R>
Source§type SingleElement = Spec<'a, T, R>
type SingleElement = Spec<'a, T, R>
Source§type MultipleElements = Spec<'a, Vec<T>, R>
type MultipleElements = Spec<'a, Vec<T>, R>
Source§fn single_element(self) -> Self::SingleElement
fn single_element(self) -> Self::SingleElement
Source§fn filtered_on<C>(self, condition: C) -> Self::MultipleElements
fn filtered_on<C>(self, condition: C) -> Self::MultipleElements
Source§fn any_satisfies<P>(self, predicate: P) -> Self::MultipleElements
fn any_satisfies<P>(self, predicate: P) -> Self::MultipleElements
Source§fn all_satisfy<P>(self, predicate: P) -> Self::MultipleElements
fn all_satisfy<P>(self, predicate: P) -> Self::MultipleElements
Source§fn none_satisfies<P>(self, predicate: P) -> Self::MultipleElements
fn none_satisfies<P>(self, predicate: P) -> Self::MultipleElements
Source§impl<S, R> AssertHasCharCount<usize> for Spec<'_, S, R>
impl<S, R> AssertHasCharCount<usize> for Spec<'_, S, R>
Source§fn has_char_count(self, expected_char_count: usize) -> Self
fn has_char_count(self, expected_char_count: usize) -> Self
Source§fn has_char_count_in_range<U>(self, expected_range: U) -> Self
fn has_char_count_in_range<U>(self, expected_range: U) -> Self
Source§fn has_char_count_less_than(self, expected_char_count: usize) -> Self
fn has_char_count_less_than(self, expected_char_count: usize) -> Self
Source§fn has_char_count_greater_than(self, expected_char_count: usize) -> Self
fn has_char_count_greater_than(self, expected_char_count: usize) -> Self
Source§fn has_at_most_char_count(self, expected_char_count: usize) -> Self
fn has_at_most_char_count(self, expected_char_count: usize) -> Self
Source§fn has_at_least_char_count(self, expected_char_count: usize) -> Self
fn has_at_least_char_count(self, expected_char_count: usize) -> Self
Source§impl<S, E, R> AssertHasDebugString<E> for Spec<'_, S, R>
impl<S, E, R> AssertHasDebugString<E> for Spec<'_, S, R>
Source§fn has_debug_string(self, expected: E) -> Self
fn has_debug_string(self, expected: E) -> Self
Source§fn does_not_have_debug_string(self, expected: E) -> Self
fn does_not_have_debug_string(self, expected: E) -> Self
Source§impl<S, E, R> AssertHasDisplayString<E> for Spec<'_, S, R>
impl<S, E, R> AssertHasDisplayString<E> for Spec<'_, S, R>
Source§fn has_display_string(self, expected: E) -> Self
fn has_display_string(self, expected: E) -> Self
Source§fn does_not_have_display_string(self, expected: E) -> Self
fn does_not_have_display_string(self, expected: E) -> Self
Source§impl<T, E, X, R> AssertHasError<X> for Spec<'_, Result<T, E>, R>
impl<T, E, X, R> AssertHasError<X> for Spec<'_, Result<T, E>, R>
Source§impl<T, E, X, R> AssertHasError<X> for Spec<'_, &Result<T, E>, R>
impl<T, E, X, R> AssertHasError<X> for Spec<'_, &Result<T, E>, R>
Source§impl<'a, T, E, X, R> AssertHasErrorMessage<X> for Spec<'a, Result<T, E>, R>
impl<'a, T, E, X, R> AssertHasErrorMessage<X> for Spec<'a, Result<T, E>, R>
Source§type ErrorMessage = Spec<'a, String, R>
type ErrorMessage = Spec<'a, String, R>
Source§fn has_error_message(self, expected: X) -> Self::ErrorMessage
fn has_error_message(self, expected: X) -> Self::ErrorMessage
Source§impl<'a, T, E, X, R> AssertHasErrorMessage<X> for Spec<'a, &Result<T, E>, R>
impl<'a, T, E, X, R> AssertHasErrorMessage<X> for Spec<'a, &Result<T, E>, R>
Source§type ErrorMessage = Spec<'a, String, R>
type ErrorMessage = Spec<'a, String, R>
Source§fn has_error_message(self, expected: X) -> Self::ErrorMessage
fn has_error_message(self, expected: X) -> Self::ErrorMessage
Source§impl<S, R> AssertHasLength<usize> for Spec<'_, S, R>
impl<S, R> AssertHasLength<usize> for Spec<'_, S, R>
Source§fn has_length(self, expected_length: usize) -> Self
fn has_length(self, expected_length: usize) -> Self
Source§fn has_length_in_range<U>(self, expected_range: U) -> Self
fn has_length_in_range<U>(self, expected_range: U) -> Self
Source§fn has_length_less_than(self, expected_length: usize) -> Self
fn has_length_less_than(self, expected_length: usize) -> Self
Source§fn has_length_greater_than(self, expected_length: usize) -> Self
fn has_length_greater_than(self, expected_length: usize) -> Self
Source§fn has_at_most_length(self, expected_length: usize) -> Self
fn has_at_most_length(self, expected_length: usize) -> Self
Source§fn has_at_least_length(self, expected_length: usize) -> Self
fn has_at_least_length(self, expected_length: usize) -> Self
Source§impl<S, E, R> AssertHasValue<E> for Spec<'_, Option<S>, R>
impl<S, E, R> AssertHasValue<E> for Spec<'_, Option<S>, R>
Source§impl<S, E, R> AssertHasValue<E> for Spec<'_, &Option<S>, R>
impl<S, E, R> AssertHasValue<E> for Spec<'_, &Option<S>, R>
Source§impl<T, E, X, R> AssertHasValue<X> for Spec<'_, Result<T, E>, R>
impl<T, E, X, R> AssertHasValue<X> for Spec<'_, Result<T, E>, R>
Source§impl<T, E, X, R> AssertHasValue<X> for Spec<'_, &Result<T, E>, R>
impl<T, E, X, R> AssertHasValue<X> for Spec<'_, &Result<T, E>, R>
Source§impl<S, E, R> AssertInRange<E> for Spec<'_, S, R>
impl<S, E, R> AssertInRange<E> for Spec<'_, S, R>
Source§fn is_in_range<U>(self, range: U) -> Selfwhere
U: RangeBounds<E> + Debug,
fn is_in_range<U>(self, range: U) -> Selfwhere
U: RangeBounds<E> + Debug,
Source§fn is_not_in_range<U>(self, range: U) -> Selfwhere
U: RangeBounds<E> + Debug,
fn is_not_in_range<U>(self, range: U) -> Selfwhere
U: RangeBounds<E> + Debug,
Source§impl<S, R> AssertInfinity for Spec<'_, S, R>
impl<S, R> AssertInfinity for Spec<'_, S, R>
Source§impl<R> AssertIsCloseToWithDefaultMargin<f32> for Spec<'_, f32, R>where
R: FailingStrategy,
Available on crate feature float-cmp only.
impl<R> AssertIsCloseToWithDefaultMargin<f32> for Spec<'_, f32, R>where
R: FailingStrategy,
float-cmp only.Source§fn is_close_to(self, expected: f32) -> Self
fn is_close_to(self, expected: f32) -> Self
Source§fn is_not_close_to(self, expected: f32) -> Self
fn is_not_close_to(self, expected: f32) -> Self
Source§impl<R> AssertIsCloseToWithDefaultMargin<f64> for Spec<'_, f64, R>where
R: FailingStrategy,
Available on crate feature float-cmp only.
impl<R> AssertIsCloseToWithDefaultMargin<f64> for Spec<'_, f64, R>where
R: FailingStrategy,
float-cmp only.Source§fn is_close_to(self, expected: f64) -> Self
fn is_close_to(self, expected: f64) -> Self
Source§fn is_not_close_to(self, expected: f64) -> Self
fn is_not_close_to(self, expected: f64) -> Self
Source§impl<R> AssertIsCloseToWithinMargin<f32, F32Margin> for Spec<'_, f32, R>where
R: FailingStrategy,
Available on crate feature float-cmp only.
impl<R> AssertIsCloseToWithinMargin<f32, F32Margin> for Spec<'_, f32, R>where
R: FailingStrategy,
float-cmp only.Source§impl<R> AssertIsCloseToWithinMargin<f64, F64Margin> for Spec<'_, f64, R>where
R: FailingStrategy,
Available on crate feature float-cmp only.
impl<R> AssertIsCloseToWithinMargin<f64, F64Margin> for Spec<'_, f64, R>where
R: FailingStrategy,
float-cmp only.Source§impl<'a, S, T, E, R> AssertIteratorContains<E> for Spec<'a, S, R>
impl<'a, S, T, E, R> AssertIteratorContains<E> for Spec<'a, S, R>
Source§type Sequence = Spec<'a, Vec<T>, R>
type Sequence = Spec<'a, Vec<T>, R>
Source§fn contains(self, expected: E) -> Self::Sequence
fn contains(self, expected: E) -> Self::Sequence
Source§fn does_not_contain(self, expected: E) -> Self::Sequence
fn does_not_contain(self, expected: E) -> Self::Sequence
Source§impl<'a, S, T, E, R> AssertIteratorContainsInAnyOrder<E> for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
T: PartialEq<<E as IntoIterator>::Item> + Debug,
E: IntoIterator,
<E as IntoIterator>::Item: Debug,
R: FailingStrategy,
impl<'a, S, T, E, R> AssertIteratorContainsInAnyOrder<E> for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
T: PartialEq<<E as IntoIterator>::Item> + Debug,
E: IntoIterator,
<E as IntoIterator>::Item: Debug,
R: FailingStrategy,
Source§type Sequence = Spec<'a, Vec<T>, R>
type Sequence = Spec<'a, Vec<T>, R>
Source§fn contains_exactly_in_any_order(self, expected: E) -> Self::Sequence
fn contains_exactly_in_any_order(self, expected: E) -> Self::Sequence
Source§fn contains_any_of(self, expected: E) -> Spec<'a, Vec<T>, R>
fn contains_any_of(self, expected: E) -> Spec<'a, Vec<T>, R>
Source§fn does_not_contain_any_of(self, expected: E) -> Spec<'a, Vec<T>, R>
fn does_not_contain_any_of(self, expected: E) -> Spec<'a, Vec<T>, R>
Source§fn contains_all_of(self, expected: E) -> Spec<'a, Vec<T>, R>
fn contains_all_of(self, expected: E) -> Spec<'a, Vec<T>, R>
Source§impl<'a, S, T, E, R> AssertIteratorContainsInOrder<E> for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
E: IntoIterator,
<E as IntoIterator>::IntoIter: DefinedOrderProperty,
<E as IntoIterator>::Item: Debug,
T: PartialEq<<E as IntoIterator>::Item> + Debug,
R: FailingStrategy,
impl<'a, S, T, E, R> AssertIteratorContainsInOrder<E> for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
E: IntoIterator,
<E as IntoIterator>::IntoIter: DefinedOrderProperty,
<E as IntoIterator>::Item: Debug,
T: PartialEq<<E as IntoIterator>::Item> + Debug,
R: FailingStrategy,
Source§type Sequence = Spec<'a, Vec<T>, R>
type Sequence = Spec<'a, Vec<T>, R>
Source§fn contains_exactly(self, expected: E) -> Self::Sequence
fn contains_exactly(self, expected: E) -> Self::Sequence
Source§fn contains_sequence(self, expected: E) -> Self::Sequence
fn contains_sequence(self, expected: E) -> Self::Sequence
Source§fn contains_all_in_order(self, expected: E) -> Self::Sequence
fn contains_all_in_order(self, expected: E) -> Self::Sequence
Source§fn starts_with(self, expected: E) -> Self::Sequence
fn starts_with(self, expected: E) -> Self::Sequence
Source§impl<S, E, R> AssertMapContainsKey<E> for Spec<'_, S, R>where
S: MapProperties + Debug,
<S as MapProperties>::Key: PartialEq<E> + Debug,
<S as MapProperties>::Value: Debug,
E: Debug,
R: FailingStrategy,
impl<S, E, R> AssertMapContainsKey<E> for Spec<'_, S, R>where
S: MapProperties + Debug,
<S as MapProperties>::Key: PartialEq<E> + Debug,
<S as MapProperties>::Value: Debug,
E: Debug,
R: FailingStrategy,
Source§fn contains_key(self, expected_key: E) -> Self
fn contains_key(self, expected_key: E) -> Self
Source§fn does_not_contain_key(self, expected_key: E) -> Self
fn does_not_contain_key(self, expected_key: E) -> Self
Source§fn contains_keys(self, expected_keys: impl IntoIterator<Item = E>) -> Self
fn contains_keys(self, expected_keys: impl IntoIterator<Item = E>) -> Self
Source§fn does_not_contain_keys(
self,
expected_keys: impl IntoIterator<Item = E>,
) -> Self
fn does_not_contain_keys( self, expected_keys: impl IntoIterator<Item = E>, ) -> Self
Source§fn contains_exactly_keys(
self,
expected_keys: impl IntoIterator<Item = E>,
) -> Self
fn contains_exactly_keys( self, expected_keys: impl IntoIterator<Item = E>, ) -> Self
Source§impl<S, E, R> AssertMapContainsValue<E> for Spec<'_, S, R>where
S: MapProperties,
<S as MapProperties>::Key: Debug,
<S as MapProperties>::Value: PartialEq<E> + Debug,
E: Debug,
R: FailingStrategy,
impl<S, E, R> AssertMapContainsValue<E> for Spec<'_, S, R>where
S: MapProperties,
<S as MapProperties>::Key: Debug,
<S as MapProperties>::Value: PartialEq<E> + Debug,
E: Debug,
R: FailingStrategy,
Source§fn contains_value(self, expected_value: E) -> Self
fn contains_value(self, expected_value: E) -> Self
Source§fn does_not_contain_value(self, expected_value: E) -> Self
fn does_not_contain_value(self, expected_value: E) -> Self
Source§fn contains_values(self, expected_values: impl IntoIterator<Item = E>) -> Self
fn contains_values(self, expected_values: impl IntoIterator<Item = E>) -> Self
Source§fn does_not_contain_values(
self,
expected_values: impl IntoIterator<Item = E>,
) -> Self
fn does_not_contain_values( self, expected_values: impl IntoIterator<Item = E>, ) -> Self
Source§impl<S, R> AssertNotANumber for Spec<'_, S, R>
impl<S, R> AssertNotANumber for Spec<'_, S, R>
Source§fn is_not_a_number(self) -> Self
fn is_not_a_number(self) -> Self
Source§fn is_a_number(self) -> Self
fn is_a_number(self) -> Self
Source§impl<S, R> AssertNumericIdentity for Spec<'_, S, R>where
S: AdditiveIdentityProperty + MultiplicativeIdentityProperty + PartialEq + Debug,
R: FailingStrategy,
impl<S, R> AssertNumericIdentity for Spec<'_, S, R>where
S: AdditiveIdentityProperty + MultiplicativeIdentityProperty + PartialEq + Debug,
R: FailingStrategy,
Source§impl<S, R> AssertOption for Spec<'_, Option<S>, R>where
S: Debug,
R: FailingStrategy,
impl<S, R> AssertOption for Spec<'_, Option<S>, R>where
S: Debug,
R: FailingStrategy,
Source§impl<S, R> AssertOption for Spec<'_, &Option<S>, R>where
S: Debug,
R: FailingStrategy,
impl<S, R> AssertOption for Spec<'_, &Option<S>, R>where
S: Debug,
R: FailingStrategy,
Source§impl<'a, T, R> AssertOptionValue for Spec<'a, Option<T>, R>where
R: FailingStrategy,
impl<'a, T, R> AssertOptionValue for Spec<'a, Option<T>, R>where
R: FailingStrategy,
Source§impl<'a, T, R> AssertOptionValue for Spec<'a, &'a Option<T>, R>where
R: FailingStrategy,
impl<'a, T, R> AssertOptionValue for Spec<'a, &'a Option<T>, R>where
R: FailingStrategy,
Source§impl<S, E, R> AssertOrder<E> for Spec<'_, S, R>
impl<S, E, R> AssertOrder<E> for Spec<'_, S, R>
Source§fn is_less_than(self, expected: E) -> Self
fn is_less_than(self, expected: E) -> Self
Source§fn is_greater_than(self, expected: E) -> Self
fn is_greater_than(self, expected: E) -> Self
Source§fn is_at_most(self, expected: E) -> Self
fn is_at_most(self, expected: E) -> Self
Source§fn is_at_least(self, expected: E) -> Self
fn is_at_least(self, expected: E) -> Self
Source§fn is_before(self, expected: E) -> Self
fn is_before(self, expected: E) -> Self
Source§fn is_after(self, expected: E) -> Self
fn is_after(self, expected: E) -> Self
Source§fn is_between(self, min: E, max: E) -> Self
fn is_between(self, min: E, max: E) -> Self
Source§impl<'a, S, T, R> AssertOrderedElements for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
T: Debug,
R: FailingStrategy,
impl<'a, S, T, R> AssertOrderedElements for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
T: Debug,
R: FailingStrategy,
Source§type SingleElement = Spec<'a, T, R>
type SingleElement = Spec<'a, T, R>
Source§type MultipleElements = Spec<'a, Vec<T>, R>
type MultipleElements = Spec<'a, Vec<T>, R>
Source§fn first_element(self) -> Self::SingleElement
fn first_element(self) -> Self::SingleElement
Source§fn last_element(self) -> Self::SingleElement
fn last_element(self) -> Self::SingleElement
Source§fn nth_element(self, n: usize) -> Self::SingleElement
fn nth_element(self, n: usize) -> Self::SingleElement
Source§fn elements_at(
self,
indices: impl IntoIterator<Item = usize>,
) -> Self::MultipleElements
fn elements_at( self, indices: impl IntoIterator<Item = usize>, ) -> Self::MultipleElements
Source§impl<'a, S, T, U, R> AssertOrderedElementsRef for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
T: 'a + ToOwned<Owned = U> + Debug,
U: Clone,
R: FailingStrategy,
impl<'a, S, T, U, R> AssertOrderedElementsRef for Spec<'a, S, R>where
S: IntoIterator<Item = T>,
<S as IntoIterator>::IntoIter: DefinedOrderProperty,
T: 'a + ToOwned<Owned = U> + Debug,
U: Clone,
R: FailingStrategy,
Source§type SingleElement = DerivedSpec<'a, Spec<'a, Vec<T>, R>, U>
type SingleElement = DerivedSpec<'a, Spec<'a, Vec<T>, R>, U>
Source§type MultipleElements = DerivedSpec<'a, Spec<'a, Vec<T>, R>, Vec<U>>
type MultipleElements = DerivedSpec<'a, Spec<'a, Vec<T>, R>, Vec<U>>
Source§fn first_element_ref(self) -> Self::SingleElement
fn first_element_ref(self) -> Self::SingleElement
Source§fn last_element_ref(self) -> Self::SingleElement
fn last_element_ref(self) -> Self::SingleElement
Source§fn nth_element_ref(self, n: usize) -> Self::SingleElement
fn nth_element_ref(self, n: usize) -> Self::SingleElement
Source§fn elements_ref_at(
self,
indices: impl IntoIterator<Item = usize>,
) -> Self::MultipleElements
fn elements_ref_at( self, indices: impl IntoIterator<Item = usize>, ) -> Self::MultipleElements
Source§impl<T, E, R> AssertResult for Spec<'_, Result<T, E>, R>
impl<T, E, R> AssertResult for Spec<'_, Result<T, E>, R>
Source§impl<T, E, R> AssertResult for Spec<'_, &Result<T, E>, R>
impl<T, E, R> AssertResult for Spec<'_, &Result<T, E>, R>
Source§impl<'a, T, E, R> AssertResultValue for Spec<'a, Result<T, E>, R>
impl<'a, T, E, R> AssertResultValue for Spec<'a, Result<T, E>, R>
Source§type Ok = Spec<'a, T, R>
type Ok = Spec<'a, T, R>
Source§impl<'a, T, E, R> AssertResultValue for Spec<'a, &'a Result<T, E>, R>
impl<'a, T, E, R> AssertResultValue for Spec<'a, &'a Result<T, E>, R>
Source§type Ok = Spec<'a, &'a T, R>
type Ok = Spec<'a, &'a T, R>
Source§impl<S, R> AssertSameAs<S> for Spec<'_, S, R>
impl<S, R> AssertSameAs<S> for Spec<'_, S, R>
Source§fn is_same_as(self, expected: S) -> Self
fn is_same_as(self, expected: S) -> Self
Source§fn is_not_same_as(self, expected: S) -> Self
fn is_not_same_as(self, expected: S) -> Self
Source§impl<S, R> AssertSignum for Spec<'_, S, R>
impl<S, R> AssertSignum for Spec<'_, S, R>
Source§fn is_negative(self) -> Self
fn is_negative(self) -> Self
Source§fn is_not_negative(self) -> Self
fn is_not_negative(self) -> Self
Source§fn is_positive(self) -> Self
fn is_positive(self) -> Self
Source§fn is_not_positive(self) -> Self
fn is_not_positive(self) -> Self
Source§impl<'a, S, R, const N: usize> AssertStringContainsAnyOf<&'a [char; N]> for Spec<'a, S, R>
impl<'a, S, R, const N: usize> AssertStringContainsAnyOf<&'a [char; N]> for Spec<'a, S, R>
Source§impl<'a, S, R> AssertStringContainsAnyOf<&'a [char]> for Spec<'a, S, R>
impl<'a, S, R> AssertStringContainsAnyOf<&'a [char]> for Spec<'a, S, R>
Source§fn contains_any_of(self, expected: &'a [char]) -> Self
fn contains_any_of(self, expected: &'a [char]) -> Self
Source§fn does_not_contain_any_of(self, expected: &'a [char]) -> Self
fn does_not_contain_any_of(self, expected: &'a [char]) -> Self
Source§impl<'a, S, R, const N: usize> AssertStringContainsAnyOf<[char; N]> for Spec<'a, S, R>
impl<'a, S, R, const N: usize> AssertStringContainsAnyOf<[char; N]> for Spec<'a, S, R>
Source§impl<S, R> AssertStringMatches for Spec<'_, S, R>
Available on crate feature regex only.
impl<S, R> AssertStringMatches for Spec<'_, S, R>
regex only.Source§impl<'a, S, R> AssertStringPattern<&'a str> for Spec<'a, S, R>
impl<'a, S, R> AssertStringPattern<&'a str> for Spec<'a, S, R>
Source§fn contains(self, pattern: &'a str) -> Self
fn contains(self, pattern: &'a str) -> Self
Source§fn does_not_contain(self, pattern: &'a str) -> Self
fn does_not_contain(self, pattern: &'a str) -> Self
Source§fn starts_with(self, pattern: &str) -> Self
fn starts_with(self, pattern: &str) -> Self
Source§fn does_not_start_with(self, pattern: &'a str) -> Self
fn does_not_start_with(self, pattern: &'a str) -> Self
Source§fn ends_with(self, pattern: &str) -> Self
fn ends_with(self, pattern: &str) -> Self
Source§fn does_not_end_with(self, pattern: &'a str) -> Self
fn does_not_end_with(self, pattern: &'a str) -> Self
Source§impl<'a, S, R> AssertStringPattern<String> for Spec<'a, S, R>
impl<'a, S, R> AssertStringPattern<String> for Spec<'a, S, R>
Source§fn contains(self, pattern: String) -> Self
fn contains(self, pattern: String) -> Self
Source§fn does_not_contain(self, pattern: String) -> Self
fn does_not_contain(self, pattern: String) -> Self
Source§fn starts_with(self, pattern: String) -> Self
fn starts_with(self, pattern: String) -> Self
Source§fn does_not_start_with(self, pattern: String) -> Self
fn does_not_start_with(self, pattern: String) -> Self
Source§fn ends_with(self, pattern: String) -> Self
fn ends_with(self, pattern: String) -> Self
Source§fn does_not_end_with(self, pattern: String) -> Self
fn does_not_end_with(self, pattern: String) -> Self
Source§impl<'a, S, R> AssertStringPattern<char> for Spec<'a, S, R>
impl<'a, S, R> AssertStringPattern<char> for Spec<'a, S, R>
Source§fn contains(self, expected: char) -> Self
fn contains(self, expected: char) -> Self
Source§fn does_not_contain(self, pattern: char) -> Self
fn does_not_contain(self, pattern: char) -> Self
Source§fn starts_with(self, expected: char) -> Self
fn starts_with(self, expected: char) -> Self
Source§fn does_not_start_with(self, pattern: char) -> Self
fn does_not_start_with(self, pattern: char) -> Self
Source§fn ends_with(self, pattern: char) -> Self
fn ends_with(self, pattern: char) -> Self
Source§fn does_not_end_with(self, pattern: char) -> Self
fn does_not_end_with(self, pattern: char) -> Self
Source§impl<S, R> DoFail for Spec<'_, S, R>where
R: FailingStrategy,
impl<S, R> DoFail for Spec<'_, S, R>where
R: FailingStrategy,
Source§fn do_fail_with(&mut self, failures: impl IntoIterator<Item = AssertFailure>)
fn do_fail_with(&mut self, failures: impl IntoIterator<Item = AssertFailure>)
AssertFailures according to the
current failing strategy of the Spec or other implementing
spec-like struct.Source§fn do_fail_with_message(&mut self, message: impl Into<String>)
fn do_fail_with_message(&mut self, message: impl Into<String>)
Spec or other implementing
spec-like struct.