Skip to content

Commit

Permalink
Fix some str docs to refer to patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
wthrowe committed Dec 8, 2015
1 parent e7f3d6e commit 34fe201
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,10 @@ impl str {
Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) }
}

/// Returns `true` if the given `&str` is a sub-slice of this string slice.
/// Returns `true` if the given pattern matches a sub-slice of
/// this string slice.
///
/// Returns `false` if it's not.
/// Returns `false` if it does not.
///
/// # Examples
///
Expand All @@ -876,9 +877,10 @@ impl str {
core_str::StrExt::contains(self, pat)
}

/// Returns `true` if the given `&str` is a prefix of this string slice.
/// Returns `true` if the given pattern matches a prefix of this
/// string slice.
///
/// Returns `false` if it's not.
/// Returns `false` if it does not.
///
/// # Examples
///
Expand All @@ -895,9 +897,10 @@ impl str {
core_str::StrExt::starts_with(self, pat)
}

/// Returns `true` if the given `&str` is a suffix of this string slice.
/// Returns `true` if the given pattern matches a suffix of this
/// string slice.
///
/// Returns `false` if not.
/// Returns `false` if it does not.
///
/// # Examples
///
Expand Down Expand Up @@ -1681,11 +1684,11 @@ impl str {
core_str::StrExt::parse(self)
}

/// Replaces all occurrences of one string with another.
/// Replaces all matches of a pattern with another string.
///
/// `replace` creates a new [`String`], and copies the data from this string slice into it.
/// While doing so, it attempts to find a sub-`&str`. If it finds it, it replaces it with
/// the replacement string slice.
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
/// replaces them with the replacement string slice.
///
/// [`String`]: string/struct.String.html
///
Expand All @@ -1699,7 +1702,7 @@ impl str {
/// assert_eq!("this is new", s.replace("old", "new"));
/// ```
///
/// When a `&str` isn't found:
/// When the pattern doesn't match:
///
/// ```
/// let s = "this is old";
Expand Down

0 comments on commit 34fe201

Please sign in to comment.