Skip to content

Commit d130acc

Browse files
committed
auto merge of #14635 : BurntSushi/rust/regex-doco-touchups, r=alexcrichton
2 parents 5a6dc40 + 179fc6d commit d130acc

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/libregex/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@
155155
//! # Unicode
156156
//!
157157
//! This implementation executes regular expressions **only** on sequences of
158-
//! UTF8 codepoints while exposing match locations as byte indices.
158+
//! Unicode code points while exposing match locations as byte indices into the
159+
//! search string.
159160
//!
160161
//! Currently, only naive case folding is supported. Namely, when matching
161162
//! case insensitively, the characters are first converted to their uppercase
162163
//! forms and then compared.
163164
//!
164165
//! Regular expressions themselves are also **only** interpreted as a sequence
165-
//! of UTF8 codepoints. This means you can embed Unicode characters directly
166-
//! into your expression:
166+
//! of Unicode code points. This means you can use Unicode characters
167+
//! directly in your expression:
167168
//!
168169
//! ```rust
169170
//! # #![feature(phase)]
@@ -229,10 +230,10 @@
229230
//! x*? zero or more of x (ungreedy)
230231
//! x+? one or more of x (ungreedy)
231232
//! x?? zero or one of x (ungreedy)
232-
//! x{n,m} at least n and at most x (greedy)
233+
//! x{n,m} at least n x and at most m x (greedy)
233234
//! x{n,} at least n x (greedy)
234235
//! x{n} exactly n x
235-
//! x{n,m}? at least n and at most x (ungreedy)
236+
//! x{n,m}? at least n x and at most m x (ungreedy)
236237
//! x{n,}? at least n x (ungreedy)
237238
//! x{n}? exactly n x
238239
//! </pre>
@@ -300,7 +301,7 @@
300301
//! \v vertical tab (\x0B)
301302
//! \123 octal character code (up to three digits)
302303
//! \x7F hex character code (exactly two digits)
303-
//! \x{10FFFF} any hex character code corresponding to a valid UTF8 codepoint
304+
//! \x{10FFFF} any hex character code corresponding to a Unicode code point
304305
//! </pre>
305306
//!
306307
//! ## Perl character classes (Unicode friendly)
@@ -390,7 +391,7 @@ mod vm;
390391
#[cfg(test, not(windows))]
391392
mod test;
392393

393-
/// The `program` module exists to support the `regex!` macro. Do not use.
394+
/// The `native` module exists to support the `regex!` macro. Do not use.
394395
#[doc(hidden)]
395396
pub mod native {
396397
// Exporting this stuff is bad form, but it's necessary for two reasons.

src/libregex/re.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ use parse;
1818
use vm;
1919
use 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.
2325
pub 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

Comments
 (0)