pub fn contains_substring<T>(expected: T) -> StrMatcher<T>Expand description
Matches a string containing a given substring.
Both the actual value and the expected substring may be either a String or
a string reference.
verify_that!("Some value", contains_substring("Some"))?; // Passes
verify_that!("Another value", contains_substring("Some"))?; // Fails
verify_that!("Some value".to_string(), contains_substring("value"))?; // Passes
verify_that!("Some value", contains_substring("value".to_string()))?; // PassesSee the StrMatcherConfigurator extension trait for more options on how
the string is matched.
Note on memory use: In most cases, this matcher does not allocate memory when matching strings. However, it must allocate copies of both the actual and expected values when matching strings while
ignoring_ascii_caseorignoring_unicode_caseare set.