From b7974bd3cd2df94d19dad467fa09a79f78067559 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 Aug 2020 01:06:11 +0100 Subject: [PATCH] docs: Reword `slice::strip_prefix` and `strip_suffix` a bit The stabilisation issue, #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 --- library/core/src/slice/mod.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index d0d88c01f5b2..1dfe899d3e5c 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1703,8 +1703,12 @@ impl [T] { /// Returns a subslice with the prefix removed. /// - /// This method returns [`None`] if slice does not start with `prefix`. - /// Also it returns the original slice if `prefix` is an empty slice. + /// If the slice starts with `prefix`, returns + /// the subslice after the prefix, wrapped in `Some`. + /// + /// If the slice does not start with `prefix`, returns `None`. + /// + /// (If `prefix` is empty, simply returns the original slice.) /// /// # Examples /// @@ -1734,8 +1738,12 @@ impl [T] { /// Returns a subslice with the suffix removed. /// - /// This method returns [`None`] if slice does not end with `suffix`. - /// Also it returns the original slice if `suffix` is an empty slice + /// If the slice ends with `suffix`, returns + /// the subslice before the suffix, wrapped in `Some`. + /// + /// If the slice does not end with `suffix`, returns `None`. + /// + /// (If `suffix` is empty, simply returns the original slice.) /// /// # Examples ///