pub struct Pattern { /* private fields */ }Expand description
A compiled glob-style pattern for matching strings.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn new(pattern: &str) -> Result<Self>
pub fn new(pattern: &str) -> Result<Self>
Create a new pattern from a glob string.
§Examples
use altium_format::query::Pattern;
let p = Pattern::new("R*").unwrap();
assert!(p.matches("R1"));
assert!(p.matches("R100"));
assert!(!p.matches("C1"));
let p = Pattern::new("R?").unwrap();
assert!(p.matches("R1"));
assert!(!p.matches("R10"));Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true if this pattern has no wildcards.
Sourcepub fn matches(&self, text: &str) -> bool
pub fn matches(&self, text: &str) -> bool
Test if a string matches this pattern (case-insensitive).
Sourcepub fn matches_case_sensitive(&self, text: &str) -> bool
pub fn matches_case_sensitive(&self, text: &str) -> bool
Test if a string matches this pattern (case-sensitive).
Trait Implementations§
impl Eq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more