@@ -18,8 +18,10 @@ use parse;
1818use vm;
1919use vm:: { CaptureLocs , MatchKind , Exists , Location , Submatches } ;
2020
21- /// Escapes all regular expression meta characters in `text` so that it may be
22- /// safely used in a regular expression as a literal string.
21+ /// Escapes all regular expression meta characters in `text`.
22+ ///
23+ /// The string returned may be safely used as a literal in a regular
24+ /// expression.
2325pub fn quote ( text : & str ) -> String {
2426 let mut quoted = String :: with_capacity ( text. len ( ) ) ;
2527 for c in text. chars ( ) {
@@ -45,17 +47,18 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
4547 Regex :: new ( regex) . map ( |r| r. is_match ( text) )
4648}
4749
48- /// Regex is a compiled regular expression, represented as either a sequence
49- /// of bytecode instructions (dynamic) or as a specialized Rust function
50- /// (native). It can be used to search, split
50+ /// A compiled regular expression
51+ ///
52+ /// It is represented as either a sequence of bytecode instructions (dynamic)
53+ /// or as a specialized Rust function (native). It can be used to search, split
5154/// or replace text. All searching is done with an implicit `.*?` at the
5255/// beginning and end of an expression. To force an expression to match the
5356/// whole string (or a prefix or a suffix), you must use an anchor like `^` or
5457/// `$` (or `\A` and `\z`).
5558///
5659/// While this crate will handle Unicode strings (whether in the regular
5760/// expression or in the search text), all positions returned are **byte
58- /// indices**. Every byte index is guaranteed to be at a UTF8 codepoint
61+ /// indices**. Every byte index is guaranteed to be at a Unicode code point
5962/// boundary.
6063///
6164/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a
@@ -189,7 +192,7 @@ impl Regex {
189192 ///
190193 /// # Example
191194 ///
192- /// Find the start and end location of every word with exactly 13
195+ /// Find the start and end location of the first word with exactly 13
193196 /// characters:
194197 ///
195198 /// ```rust
@@ -216,7 +219,7 @@ impl Regex {
216219 ///
217220 /// # Example
218221 ///
219- /// Find the start and end location of the first word with exactly 13
222+ /// Find the start and end location of every word with exactly 13
220223 /// characters:
221224 ///
222225 /// ```rust
@@ -577,8 +580,8 @@ impl<'t> Replacer for &'t str {
577580 }
578581}
579582
580- impl < ' a > Replacer for |& Captures |: ' a -> String {
581- fn reg_replace<' r >( & ' r mut self , caps : & Captures ) -> MaybeOwned < ' r > {
583+ impl < ' t > Replacer for |& Captures |: ' t -> String {
584+ fn reg_replace<' a >( & ' a mut self , caps : & Captures ) -> MaybeOwned < ' a > {
582585 Owned ( ( * self ) ( caps) )
583586 }
584587}
@@ -823,8 +826,9 @@ impl<'t> Iterator<Option<(uint, uint)>> for SubCapturesPos<'t> {
823826}
824827
825828/// An iterator that yields all non-overlapping capture groups matching a
826- /// particular regular expression. The iterator stops when no more matches can
827- /// be found.
829+ /// particular regular expression.
830+ ///
831+ /// The iterator stops when no more matches can be found.
828832///
829833/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime
830834/// of the matched string.
0 commit comments