From 8b2e79dbac324b703493113c9f823e63cf1df4e0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 27 Dec 2020 00:53:02 +0000 Subject: [PATCH] Add test for slice as prefix/suffix pattern Signed-off-by: Ian Jackson --- library/core/src/slice/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) 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] { /// 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")]