Struct pretty_assertions::StrComparison
source · [−]pub struct StrComparison<'a, TLeft, TRight>where
TLeft: ?Sized,
TRight: ?Sized,{ /* private fields */ }
Expand description
A comparison of two strings.
In contrast to Comparison
, which uses the core::fmt::Debug
representation,
StrComparison
uses the string values directly, resulting in multi-line output for multiline strings.
use pretty_assertions::StrComparison;
print!("{}", StrComparison::new("foo\nbar", "foo\nbaz"));
Value type bounds
Any value that can be referenced as a str
via AsRef
may be used:
use pretty_assertions::StrComparison;
#[derive(PartialEq)]
struct MyString(String);
impl AsRef<str> for MyString {
fn as_ref(&self) -> &str {
&self.0
}
}
print!(
"{}",
StrComparison::new(
&MyString("foo\nbar".to_owned()),
&MyString("foo\nbaz".to_owned()),
),
);
The values may have different types, although in practice they are usually the same.
Implementations
sourceimpl<'a, TLeft, TRight> StrComparison<'a, TLeft, TRight>where
TLeft: AsRef<str> + ?Sized,
TRight: AsRef<str> + ?Sized,
impl<'a, TLeft, TRight> StrComparison<'a, TLeft, TRight>where
TLeft: AsRef<str> + ?Sized,
TRight: AsRef<str> + ?Sized,
sourcepub fn new(
left: &'a TLeft,
right: &'a TRight
) -> StrComparison<'a, TLeft, TRight>
pub fn new(
left: &'a TLeft,
right: &'a TRight
) -> StrComparison<'a, TLeft, TRight>
Store two values to be compared in future.
Expensive diffing is deferred until calling Debug::fmt
.
Trait Implementations
Auto Trait Implementations
impl<'a, TLeft: ?Sized, TRight: ?Sized> RefUnwindSafe for StrComparison<'a, TLeft, TRight>where
TLeft: RefUnwindSafe,
TRight: RefUnwindSafe,
impl<'a, TLeft: ?Sized, TRight: ?Sized> Send for StrComparison<'a, TLeft, TRight>where
TLeft: Sync,
TRight: Sync,
impl<'a, TLeft: ?Sized, TRight: ?Sized> Sync for StrComparison<'a, TLeft, TRight>where
TLeft: Sync,
TRight: Sync,
impl<'a, TLeft: ?Sized, TRight: ?Sized> Unpin for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft: ?Sized, TRight: ?Sized> UnwindSafe for StrComparison<'a, TLeft, TRight>where
TLeft: RefUnwindSafe,
TRight: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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