[−][src]Function os_str_bytes::raw::starts_with
#[must_use]pub fn starts_with<TString: ?Sized>(string: &TString, prefix: &[u8]) -> bool where
TString: AsRef<[u8]>,
Returns true
if and only if the encoded bytes start with the given
prefix.
The prefix is typed to not accept strings, because they do not make sense
to pass as the second argument to this function. While they will give the
expected result, slice::starts_with
is more efficient to use in that
case.
Panics
Either panics or returns an unspecified result if either sequence is invalid.
Examples
use std::ffi::OsStr; use os_str_bytes::OsStrBytes; use os_str_bytes::raw; let os_string = OsStr::new("foo"); let os_bytes = os_string.to_bytes(); assert!(raw::starts_with("foobar", &os_bytes));