Skip to content

Commit

Permalink
api: implement Clone for SubCaptureMatches
Browse files Browse the repository at this point in the history
This is useful in a generic context when you want to iterate over
something twice. There's not much reason to not do it at least.

Closes #689
  • Loading branch information
benesch authored and BurntSushi committed Oct 11, 2020
1 parent 2c1056a commit 81d751f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/re_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ impl<'t, 'i> Index<&'i str> for Captures<'t> {
///
/// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and
/// the lifetime `'t` corresponds to the originally matched text.
#[derive(Clone)]
pub struct SubCaptureMatches<'c, 't: 'c> {
caps: &'c Captures<'t>,
it: SubCapturesPosIter<'c>,
Expand Down
1 change: 1 addition & 0 deletions src/re_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl Locations {
/// Positions are byte indices in terms of the original string matched.
///
/// `'c` is the lifetime of the captures.
#[derive(Clone)]
pub struct SubCapturesPosIter<'c> {
idx: usize,
locs: &'c Locations,
Expand Down
1 change: 1 addition & 0 deletions src/re_unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ impl<'t, 'i> Index<&'i str> for Captures<'t> {
///
/// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and
/// the lifetime `'t` corresponds to the originally matched text.
#[derive(Clone)]
pub struct SubCaptureMatches<'c, 't: 'c> {
caps: &'c Captures<'t>,
it: SubCapturesPosIter<'c>,
Expand Down

0 comments on commit 81d751f

Please sign in to comment.