diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-12-30 21:01:36 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-12-30 21:01:36 +1100 |
| commit | b7832ed0b42a2d6512e3f8d09605986237f02ed5 (patch) | |
| tree | 313e9f72ae737775db85764279a79122f4d8b458 /src/libregex | |
| parent | fea5aa656ff4349f4d3e1fea1447d26986762ae1 (diff) | |
| download | rust-b7832ed0b42a2d6512e3f8d09605986237f02ed5.tar.gz rust-b7832ed0b42a2d6512e3f8d09605986237f02ed5.zip | |
Implement `Clone` for a large number of iterators & other adaptors.
It's useful to be able to save state.
Diffstat (limited to 'src/libregex')
| -rw-r--r-- | src/libregex/re.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libregex/re.rs b/src/libregex/re.rs index 4383192edaf..51c23463155 100644 --- a/src/libregex/re.rs +++ b/src/libregex/re.rs @@ -539,6 +539,7 @@ impl Regex { } +#[deriving(Clone)] pub enum NamesIter<'a> { NamesIterNative(::std::slice::Iter<'a, Option<&'static str>>), NamesIterDynamic(::std::slice::Iter<'a, Option<String>>) @@ -595,6 +596,7 @@ impl<F> Replacer for F where F: FnMut(&Captures) -> String { /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the string being split. +#[deriving(Clone)] pub struct RegexSplits<'r, 't> { finder: FindMatches<'r, 't>, last: uint, @@ -628,6 +630,7 @@ impl<'r, 't> Iterator<&'t str> for RegexSplits<'r, 't> { /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the string being split. +#[deriving(Clone)] pub struct RegexSplitsN<'r, 't> { splits: RegexSplits<'r, 't>, cur: uint, @@ -791,6 +794,7 @@ impl<'t> Captures<'t> { /// expression. /// /// `'t` is the lifetime of the matched text. +#[deriving(Clone)] pub struct SubCaptures<'t> { idx: uint, caps: &'t Captures<'t>, @@ -813,6 +817,7 @@ impl<'t> Iterator<&'t str> for SubCaptures<'t> { /// Positions are byte indices in terms of the original string matched. /// /// `'t` is the lifetime of the matched text. +#[deriving(Clone)] pub struct SubCapturesPos<'t> { idx: uint, caps: &'t Captures<'t>, @@ -836,6 +841,7 @@ impl<'t> Iterator<Option<(uint, uint)>> for SubCapturesPos<'t> { /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the matched string. +#[deriving(Clone)] pub struct FindCaptures<'r, 't> { re: &'r Regex, search: &'t str, @@ -878,6 +884,7 @@ impl<'r, 't> Iterator<Captures<'t>> for FindCaptures<'r, 't> { /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the matched string. +#[deriving(Clone)] pub struct FindMatches<'r, 't> { re: &'r Regex, search: &'t str, |
