Add test for slice as prefix/suffix pattern
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
parent
03b4ea463a
commit
8b2e79dbac
@ -1783,6 +1783,10 @@ impl<T> [T] {
|
|||||||
/// assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..]));
|
/// assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..]));
|
||||||
/// assert_eq!(v.strip_prefix(&[50]), None);
|
/// assert_eq!(v.strip_prefix(&[50]), None);
|
||||||
/// assert_eq!(v.strip_prefix(&[10, 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"]
|
#[must_use = "returns the subslice without modifying the original"]
|
||||||
#[stable(feature = "slice_strip", since = "1.50.0")]
|
#[stable(feature = "slice_strip", since = "1.50.0")]
|
||||||
|
Loading…
Reference in New Issue
Block a user