about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2020-12-27 00:53:02 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2020-12-27 01:15:48 +0000
commit8b2e79dbac324b703493113c9f823e63cf1df4e0 (patch)
tree90d77c863d2d640ad5611243143ed7e433e6c56a
parent03b4ea463a8b2e45032e9cd6f7e293561b01c3ce (diff)
downloadrust-8b2e79dbac324b703493113c9f823e63cf1df4e0.tar.gz
rust-8b2e79dbac324b703493113c9f823e63cf1df4e0.zip
Add test for slice as prefix/suffix pattern
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rw-r--r--library/core/src/slice/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index 23830548f68..fb6d9156cea 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -1783,6 +1783,10 @@ impl<T> [T] {
     /// assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..]));
     /// assert_eq!(v.strip_prefix(&[50]), None);
     /// assert_eq!(v.strip_prefix(&[10, 50]), None);
+    ///
+    /// let prefix : &str = "he";
+    /// assert_eq!(b"hello".strip_prefix(prefix.as_bytes()),
+    ///            Some(b"llo".as_ref()));
     /// ```
     #[must_use = "returns the subslice without modifying the original"]
     #[stable(feature = "slice_strip", since = "1.50.0")]