[][src]Function os_str_bytes::raw::ends_with

#[must_use]pub fn ends_with<TString: ?Sized>(string: &TString, suffix: &[u8]) -> bool where
    TString: AsRef<[u8]>, 

Returns true if and only if the encoded bytes end with the given suffix.

The suffix 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::ends_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("bar");
let os_bytes = os_string.to_bytes();
assert!(raw::ends_with("foobar", &os_bytes));