Skip to content

Commit

Permalink
api: add From<Match> conversions for Range<usize>
Browse files Browse the repository at this point in the history
This builds on top of the previous commit which adds a new `range`
method to the `Match` types.

Closes #631
  • Loading branch information
nvzqz authored and BurntSushi committed Jan 9, 2020
1 parent 0131a92 commit 2909aee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
==================
This is a small maintenance release with some house cleaning and bug fixes.

New features:

* [FEATURE #631](https://github.com/rust-lang/regex/issues/631):
Add a `Match::range` method an a `From<Match> for Range` impl.

Bug fixes:

* [BUG #633](https://github.com/rust-lang/regex/pull/633):
Expand Down
6 changes: 6 additions & 0 deletions src/re_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ impl<'t> Match<'t> {
}
}

impl<'t> From<Match<'t>> for Range<usize> {
fn from(m: Match<'t>) -> Range<usize> {
m.range()
}
}

/// A compiled regular expression for matching arbitrary bytes.
///
/// It can be used to search, split or replace text. All searching is done with
Expand Down
6 changes: 6 additions & 0 deletions src/re_unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ impl<'t> From<Match<'t>> for &'t str {
}
}

impl<'t> From<Match<'t>> for Range<usize> {
fn from(m: Match<'t>) -> Range<usize> {
m.range()
}
}

/// A compiled regular expression for matching Unicode strings.
///
/// It is represented as either a sequence of bytecode instructions (dynamic)
Expand Down

0 comments on commit 2909aee

Please sign in to comment.