Add test for slice as prefix/suffix pattern

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
Ian Jackson 2020-12-27 00:53:02 +00:00
parent 03b4ea463a
commit 8b2e79dbac

View File

@ -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")]