Skip to content

Commit

Permalink
Implement fmt::Debug for Captures (fix rust-lang#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Feb 8, 2016
1 parent aae73b0 commit 088d52d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,21 @@ impl<'t> Index<&'t str> for Captures<'t> {

}

impl<'t> fmt::Debug for Captures<'t> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(writeln!(f, "Captures of {}:", self.text));
for i in 0..self.locs.len() {
try!(writeln!(f, "{}:\t{:?}", i, self.at(i)));
}
if let Some(ref h) = self.named {
for (n, i) in h.iter() {
try!(writeln!(f, "{}:\t{:?}", n, self.at(*i)));
}
}
Ok(())
}
}

/// An iterator over capture groups for a particular match of a regular
/// expression.
///
Expand Down

0 comments on commit 088d52d

Please sign in to comment.