-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: Add as_match method #1227
base: master
Are you sure you want to change the base?
api: Add as_match method #1227
Conversation
To simplify getting the whole match from Captures
src/regex/bytes.rs
Outdated
/// Return the overall match for the capture. | ||
/// | ||
/// This returns the match for index `0`. That is it is equivalent to | ||
/// `get(0).unwrap()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use m.get(0).unwrap()
?
@@ -1665,6 +1665,15 @@ impl<'h> Captures<'h> { | |||
.map(|sp| Match::new(self.haystack, sp.start, sp.end)) | |||
} | |||
|
|||
/// Return the overall match for the capture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an example. I try to include an example for every public API item.
/// let caps = re.captures(b" abc123-def").unwrap(); | ||
/// | ||
/// assert_eq!(caps.as_match().as_bytes(), b"abc123"); | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is not formatted in the same way as all other examples.
Please look at other public API items and format this one in the same way. It should have an # Example
heading, for example.
Also, I think the name |
To simplify getting the whole match from Captures
Fixes #1146