[−][src]Struct sanitize_html::rules::pattern::Pattern
Value pattern
Methods
impl Pattern
[src]
pub fn any() -> Self
[src]
Creates pattern which accepts any value.
Example
use sanitize_html::rules::pattern::Pattern; use regex::Regex; let pattern = Pattern::any(); assert!(pattern.matches("")); assert!(pattern.matches("pants"));
pub fn regex(re: Regex) -> Self
[src]
Creates pattern which uses regular expression to check a value. Panics
Example
use sanitize_html::rules::pattern::Pattern; use regex::Regex; let pattern = Pattern::regex(Regex::new("ant").unwrap()); assert!(!pattern.matches("")); assert!(pattern.matches("pants"));
pub fn matches(&self, value: &str) -> bool
[src]
Checks if a value matches to a pattern.
Trait Implementations
impl Not for Pattern
[src]
type Output = Pattern
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
Negates pattern
Example
use sanitize_html::rules::pattern::Pattern; use regex::Regex; let pattern = !Pattern::any(); assert!(!pattern.matches("")); assert!(!pattern.matches("pants"));
impl BitAnd<Pattern> for Pattern
[src]
type Output = Pattern
The resulting type after applying the &
operator.
fn bitand(self, rhs: Pattern) -> Self::Output
[src]
Combines two patterns into a pattern which matches a string iff both patterns match that string.
Example
use sanitize_html::rules::pattern::Pattern; use regex::Regex; let pan = Pattern::regex(Regex::new("pan").unwrap()); let ant = Pattern::regex(Regex::new("ant").unwrap()); let pattern = pan & ant; assert!(!pattern.matches("pan")); assert!(!pattern.matches("ant")); assert!(pattern.matches("pants"));
impl BitOr<Pattern> for Pattern
[src]
type Output = Pattern
The resulting type after applying the |
operator.
fn bitor(self, rhs: Pattern) -> Self::Output
[src]
Combines two patterns into a pattern which matches a string if one of patterns matches that string.
Example
use sanitize_html::rules::pattern::Pattern; use regex::Regex; let pan = Pattern::regex(Regex::new("pan").unwrap()); let pot = Pattern::regex(Regex::new("pot").unwrap()); let pattern = pan | pot; assert!(pattern.matches("pants")); assert!(pattern.matches("pot")); assert!(!pattern.matches("jar"));
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,