File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -1668,7 +1668,16 @@ impl<'h> Captures<'h> {
1668
1668
/// Return the overall match for the capture.
1669
1669
///
1670
1670
/// This returns the match for index `0`. That is it is equivalent to
1671
- /// `get(0).unwrap()`
1671
+ /// `m.get(0).unwrap()`
1672
+ ///
1673
+ /// ```
1674
+ /// use regex::bytes::Regex;
1675
+ ///
1676
+ /// let re = Regex::new(r"[a-z]+([0-9]+)").unwrap();
1677
+ /// let caps = re.captures(b" abc123-def").unwrap();
1678
+ ///
1679
+ /// assert_eq!(caps.as_match().as_bytes(), b"abc123");
1680
+ /// ```
1672
1681
#[ inline]
1673
1682
pub fn as_match ( & self ) -> Match {
1674
1683
self . get ( 0 ) . unwrap ( )
Original file line number Diff line number Diff line change @@ -1678,7 +1678,17 @@ impl<'h> Captures<'h> {
1678
1678
/// Return the overall match for the capture.
1679
1679
///
1680
1680
/// This returns the match for index `0`. That is it is equivalent to
1681
- /// `get(0).unwrap()`
1681
+ /// `m.get(0).unwrap()`
1682
+ ///
1683
+ /// ```
1684
+ /// use regex::Regex;
1685
+ ///
1686
+ /// let re = Regex::new(r"[a-z]+([0-9]+)").unwrap();
1687
+ /// let caps = re.captures(" abc123-def").unwrap();
1688
+ ///
1689
+ /// assert_eq!(caps.as_match().as_str(), "abc123");
1690
+ ///
1691
+ /// ```
1682
1692
#[ inline]
1683
1693
pub fn as_match ( & self ) -> Match {
1684
1694
self . get ( 0 ) . unwrap ( )
You can’t perform that action at this time.
0 commit comments