pub struct PatternMatchRecognizer;Expand description
Recognizes pattern matching structures
Implementations§
Source§impl PatternMatchRecognizer
impl PatternMatchRecognizer
pub fn new() -> Self
Sourcepub fn has_immediate_return(&self, block: &Block) -> bool
pub fn has_immediate_return(&self, block: &Block) -> bool
Check if an expression has an immediate return
Sourcepub fn extract_tested_variable(&self, expr: &Expr) -> Option<String>
pub fn extract_tested_variable(&self, expr: &Expr) -> Option<String>
Extract the variable being tested in a condition
Sourcepub fn extract_field_path(&self, expr: &Expr) -> Option<String>
pub fn extract_field_path(&self, expr: &Expr) -> Option<String>
Extract field path like self.field or obj.field
Sourcepub fn detect_pattern_type(&self, expr: &Expr) -> PatternType
pub fn detect_pattern_type(&self, expr: &Expr) -> PatternType
Detect the type of pattern being matched
Trait Implementations§
Source§impl Default for PatternMatchRecognizer
impl Default for PatternMatchRecognizer
Source§impl PatternRecognizer for PatternMatchRecognizer
impl PatternRecognizer for PatternMatchRecognizer
fn detect(&self, block: &Block) -> Option<PatternMatchInfo>
fn adjust_complexity(&self, info: &PatternMatchInfo, _base: u32) -> u32
Auto Trait Implementations§
impl Freeze for PatternMatchRecognizer
impl RefUnwindSafe for PatternMatchRecognizer
impl Send for PatternMatchRecognizer
impl Sync for PatternMatchRecognizer
impl Unpin for PatternMatchRecognizer
impl UnwindSafe for PatternMatchRecognizer
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> 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