Trait predicates::prelude::PredicateStrExt[][src]

pub trait PredicateStrExt where
    Self: Predicate<str>,
    Self: Sized
{ fn trim(self) -> TrimPredicate<Self> { ... }
fn from_utf8(self) -> Utf8Predicate<Self> { ... } }

Predicate extension adapting a str Predicate.

Provided Methods

Returns a TrimPredicate that ensures the data passed to Self is trimmed.


use predicates::prelude::*;

let predicate_fn = predicate::str::is_empty().trim();
assert_eq!(true, predicate_fn.eval("    "));
assert_eq!(false, predicate_fn.eval("    Hello    "));

Returns a Utf8Predicate that adapts Self to a [u8] Predicate.


use predicates::prelude::*;
use std::ffi::OsStr;

let predicate_fn = predicate::str::is_empty().not().from_utf8();
assert_eq!(true, predicate_fn.eval(OsStr::new("Hello")));
assert_eq!(false, predicate_fn.eval(OsStr::new("")));
let variable: &[u8] = b"";
assert_eq!(false, predicate_fn.eval(variable));