4 ms·
Interesting! Can you help me understand why this doesn't work for me? error[E0599]: no method named `parse` found for enum `Option<regex::Match<'_>>` in th
by mikepurvis 6y ago
Interesting! Can you help me understand why this doesn't work for me?
error[E0599]: no method named `parse` found for enum `Option<regex::Match<'_>>` in the current scope
--> src\main.rs:24:39
|
24 | min: caps.name("min").parse().unwrap(),
| ^^^^^ method not found in `Option<regex::Match<'_>>`
- abhijat 6y agoI think you need .name("min")?.as_str() to access the underlying text of the match object (after making sure it is a valid match with the ?), which can then be parsed. The regex Match object itself does not have a parse method that I can see. I don't know what the structure Input looks like but I played around with your code and it seems to work with as_str() https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b62ccb0b7b800deafef93998299fa755 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- kochismo 6y agocaps.name("min") returns an Option which you need to handle e.g. by unwrapping. You can use caps["min"] instead if you don't want an option.