79175269

Date: 2024-11-10 16:29:46
Score: 1.5
Natty:
Report link

I think the most concise way I found is to use @Jonathan Feenstra suggestion with some destructuring:

if let Some((_, [_, name, company])) =
    pattern1.captures(&text).map(|capture| capture.extract()) {
        do_something_with(name, company);
    }
    else if pattern2.is_match(&text) {
        do_something_else();
    }
}
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Jonathan
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Miguel Wang