diff options
| author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2020-08-03 01:01:52 +0100 |
|---|---|---|
| committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2020-10-12 14:47:55 +0100 |
| commit | dbb058302388824b717816b42bbfbc00330fa36d (patch) | |
| tree | ff67041512406a27f186d3a78884f4d55a2d924e | |
| parent | a8d6da3f57f9cc85ddbe1d73e72e3523de7ac245 (diff) | |
| download | rust-dbb058302388824b717816b42bbfbc00330fa36d.tar.gz rust-dbb058302388824b717816b42bbfbc00330fa36d.zip | |
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 <ijackson@chiark.greenend.org.uk>
| -rw-r--r-- | library/core/src/str/mod.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 3e18a4e7062..e6c37b6ba59 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1964,11 +1964,12 @@ impl str { /// Returns a string slice with the prefix removed. /// - /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where - /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly - /// once. + /// If the string starts with the pattern `prefix`, returns + /// substring after the prefix, wrapped in `Some`. + /// Unlike `trim_start_matches`, this method removes the + /// prefix exactly once. /// - /// If the string does not start with `prefix`, `None` is returned. + /// If the string does not start with `prefix`, returns `None`. /// /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. @@ -1992,11 +1993,12 @@ impl str { /// Returns a string slice with the suffix removed. /// - /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where - /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly - /// once. + /// If the string ends with the pattern `suffix`, returns the + /// substring before the suffix, wrapped in `Some`. + /// Unlike `trim_end_matches`, this method removes the + /// suffix exactly once. /// - /// If the string does not end with `suffix`, `None` is returned. + /// If the string does not end with `suffix`, returns `None`. /// /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. |
