// option. This file may not be copied, modified, or distributed
// except according to those terms.
+pub use self::NamesIter::*;
+pub use self::Regex::*;
+
use std::collections::HashMap;
use std::fmt;
-use std::from_str::from_str;
use std::str::{MaybeOwned, Owned, Slice};
use compile::Program;
/// Replacer describes types that can be used to replace matches in a string.
pub trait Replacer {
/// Returns a possibly owned string that is used to replace the match
- /// corresponding the the `caps` capture group.
+ /// corresponding to the `caps` capture group.
///
/// The `'a` lifetime refers to the lifetime of a borrowed string when
/// a new owned string isn't needed (e.g., for `NoExpand`).
match self.named {
None => "",
Some(ref h) => {
- match h.find_equiv(name) {
+ match h.get(name) {
None => "",
Some(i) => self.at(*i),
}
let re = Regex::new(r"\$\$").unwrap();
re.replace_all(text.as_slice(), NoExpand("$"))
}
-}
-impl<'t> Collection for Captures<'t> {
/// Returns the number of captured groups.
#[inline]
- fn len(&self) -> uint {
- self.locs.len() / 2
- }
+ pub fn len(&self) -> uint { self.locs.len() / 2 }
+
+ /// Returns if there are no captured groups.
+ #[inline]
+ pub fn is_empty(&self) -> bool { self.len() == 0 }
}
/// An iterator over capture groups for a particular match of a regular