Skip to content

Commit b7974bd

Browse files
committed
docs: Reword slice::strip_prefix and strip_suffix a bit
The stabilisation issue, rust-lang#73413, has an open item for documentation. I looked at the docs and it is all there, but I felt it could do with some minor wording improvement. I looked at the `str::strip_prefix` docs for a template. (That resulted in me slightly changing that doc too.) I de-linkified `None` and `Some`, as I felt that rather noisy.. I searched stdlib, and these don't seem to be usually linkified. Signed-off-by: Ian Jackson <[email protected]>
1 parent dbb0583 commit b7974bd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

library/core/src/slice/mod.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1703,8 +1703,12 @@ impl<T> [T] {
17031703

17041704
/// Returns a subslice with the prefix removed.
17051705
///
1706-
/// This method returns [`None`] if slice does not start with `prefix`.
1707-
/// Also it returns the original slice if `prefix` is an empty slice.
1706+
/// If the slice starts with `prefix`, returns
1707+
/// the subslice after the prefix, wrapped in `Some`.
1708+
///
1709+
/// If the slice does not start with `prefix`, returns `None`.
1710+
///
1711+
/// (If `prefix` is empty, simply returns the original slice.)
17081712
///
17091713
/// # Examples
17101714
///
@@ -1734,8 +1738,12 @@ impl<T> [T] {
17341738

17351739
/// Returns a subslice with the suffix removed.
17361740
///
1737-
/// This method returns [`None`] if slice does not end with `suffix`.
1738-
/// Also it returns the original slice if `suffix` is an empty slice
1741+
/// If the slice ends with `suffix`, returns
1742+
/// the subslice before the suffix, wrapped in `Some`.
1743+
///
1744+
/// If the slice does not end with `suffix`, returns `None`.
1745+
///
1746+
/// (If `suffix` is empty, simply returns the original slice.)
17391747
///
17401748
/// # Examples
17411749
///

0 commit comments

Comments
 (0)