pub struct StrComparison<'a, TLeft, TRight>{ /* 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§
Source§impl<'a, TLeft, TRight> StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> StrComparison<'a, TLeft, TRight>
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, TRight> Freeze for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> RefUnwindSafe for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> Send for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> Sync for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> Unpin for StrComparison<'a, TLeft, TRight>
impl<'a, TLeft, TRight> UnwindSafe for StrComparison<'a, TLeft, TRight>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more