]> git.lizzy.rs Git - rust.git/blobdiff - src/libregex/re.rs
rollup merge of #19038: jayelm/fixed-typos
[rust.git] / src / libregex / re.rs
index eebe9b85e3b9daaf070898df0ef56cf5ec990b41..e70491a785c370b27ecb643153559eb1a3ece86b 100644 (file)
@@ -8,9 +8,11 @@
 // 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;
@@ -76,7 +78,7 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
 /// # use regex::Regex;
 /// let re = match Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}") {
 ///     Ok(re) => re,
-///     Err(err) => fail!("{}", err),
+///     Err(err) => panic!("{}", err),
 /// };
 /// assert_eq!(re.find("phone: 111-222-3333"), Some((7, 19)));
 /// ```
@@ -559,7 +561,7 @@ fn next(&mut self) -> Option<Option<String>> {
 /// 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`).
@@ -724,7 +726,7 @@ pub fn name(&self, name: &str) -> &'t str {
         match self.named {
             None => "",
             Some(ref h) => {
-                match h.find_equiv(&name) {
+                match h.get(name) {
                     None => "",
                     Some(i) => self.at(*i),
                 }
@@ -772,14 +774,14 @@ pub fn expand(&self, text: &str) -> String {
         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