pub struct StepPattern { /* private fields */ }Expand description
Pattern text used to match a step at runtime.
Implementations§
Source§impl StepPattern
impl StepPattern
Sourcepub const fn new(value: &'static str) -> Self
pub const fn new(value: &'static str) -> Self
Create a new pattern wrapper from a string literal.
Sourcepub fn compile(&self) -> Result<(), StepPatternError>
pub fn compile(&self) -> Result<(), StepPatternError>
Compile the pattern into a regular expression, caching the result.
§Errors
Returns an error if the pattern contains invalid placeholders or the generated regex fails to compile.
§Notes
- This operation is idempotent. Subsequent calls after a successful compilation are no-ops.
- This method is thread-safe; concurrent calls may race to build a
Regex, but only the first successful value is cached.
Sourcepub fn specificity(&self) -> Result<SpecificityScore, StepPatternError>
pub fn specificity(&self) -> Result<SpecificityScore, StepPatternError>
Calculate and cache the specificity score for this pattern.
Used to rank patterns when multiple match the same step text. Higher scores indicate more specific patterns.
§Errors
Returns StepPatternError if the pattern contains invalid syntax.
§Notes
- This operation is idempotent. Subsequent calls after a successful calculation are no-ops.
- This method is thread-safe; concurrent calls may race to compute the score, but only the first successful value is cached.
§Examples
use rstest_bdd::StepPattern;
let specific = StepPattern::from("overlap apples");
let generic = StepPattern::from("overlap {item}");
let specific_score = specific.specificity().expect("specific pattern is valid");
let generic_score = generic.specificity().expect("generic pattern is valid");
assert!(specific_score > generic_score);Trait Implementations§
Source§impl Debug for StepPattern
impl Debug for StepPattern
Source§impl From<&'static str> for StepPattern
impl From<&'static str> for StepPattern
Source§impl Hash for StepPattern
impl Hash for StepPattern
Source§impl PartialEq for StepPattern
impl PartialEq for StepPattern
impl Eq for StepPattern
Auto Trait Implementations§
impl !Freeze for StepPattern
impl RefUnwindSafe for StepPattern
impl Send for StepPattern
impl Sync for StepPattern
impl Unpin for StepPattern
impl UnwindSafe for StepPattern
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<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.