HasPrefix

Function HasPrefix 

Source
pub fn HasPrefix(s: impl AsRef<[byte]>, prefix: impl AsRef<[byte]>) -> bool
Expand description

HasPrefix tests whether the byte slice s begins with prefix.

zh-cn 判断s是否有前缀切片prefix。

§Example

use gostd_bytes as bytes;

assert_eq!(true,bytes::HasPrefix("Rustacean","Rust"));
assert_eq!(false,bytes::HasPrefix("Rustacean","c"));
assert_eq!(true,bytes::HasPrefix("Rustacean",""));
assert_eq!(true,bytes::HasPrefix("Gopher","Go"));