From 81d751f0cfa547dcefcb8660cfb2163079457462 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Sat, 6 Jun 2020 14:08:59 -0400 Subject: [PATCH] api: implement Clone for SubCaptureMatches 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 --- src/re_bytes.rs | 1 + src/re_trait.rs | 1 + src/re_unicode.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/re_bytes.rs b/src/re_bytes.rs index b5a7219d79..189bed5fd5 100644 --- a/src/re_bytes.rs +++ b/src/re_bytes.rs @@ -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>, diff --git a/src/re_trait.rs b/src/re_trait.rs index b56804ef01..d14a9f7613 100644 --- a/src/re_trait.rs +++ b/src/re_trait.rs @@ -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, diff --git a/src/re_unicode.rs b/src/re_unicode.rs index c23b7719bc..7a0e34951b 100644 --- a/src/re_unicode.rs +++ b/src/re_unicode.rs @@ -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>,