Skip to content

Commit dbb0583

Browse files
committed
docs: Reword str::strip_prefix and strip_suffix a bit
"Some is returned with <some value>" is an awkward construction. The use of the passive voice is a bit odd, and doesn't seem like the house style. So say instead "returns X, wrapped in `Some`", for which there is some other precedent in stdlib. Instead of repeating "with the prefix removed", say "after the prefix". This is a bit clearer that the original is not modified. Signed-off-by: Ian Jackson <[email protected]>
1 parent a8d6da3 commit dbb0583

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

library/core/src/str/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -1964,11 +1964,12 @@ impl str {
19641964

19651965
/// Returns a string slice with the prefix removed.
19661966
///
1967-
/// If the string starts with the pattern `prefix`, `Some` is returned with the substring where
1968-
/// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly
1969-
/// once.
1967+
/// If the string starts with the pattern `prefix`, returns
1968+
/// substring after the prefix, wrapped in `Some`.
1969+
/// Unlike `trim_start_matches`, this method removes the
1970+
/// prefix exactly once.
19701971
///
1971-
/// If the string does not start with `prefix`, `None` is returned.
1972+
/// If the string does not start with `prefix`, returns `None`.
19721973
///
19731974
/// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
19741975
/// function or closure that determines if a character matches.
@@ -1992,11 +1993,12 @@ impl str {
19921993

19931994
/// Returns a string slice with the suffix removed.
19941995
///
1995-
/// If the string ends with the pattern `suffix`, `Some` is returned with the substring where
1996-
/// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly
1997-
/// once.
1996+
/// If the string ends with the pattern `suffix`, returns the
1997+
/// substring before the suffix, wrapped in `Some`.
1998+
/// Unlike `trim_end_matches`, this method removes the
1999+
/// suffix exactly once.
19982000
///
1999-
/// If the string does not end with `suffix`, `None` is returned.
2001+
/// If the string does not end with `suffix`, returns `None`.
20002002
///
20012003
/// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
20022004
/// function or closure that determines if a character matches.

0 commit comments

Comments
 (0)