ContainsRune

Function ContainsRune 

Source
pub fn ContainsRune(b: impl AsRef<[byte]>, r: rune) -> bool
Expand description

ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.

zh-cn 判断字节切片b是否包含utf-8码值r

§Example

use gostd_bytes as bytes;

// '中' as rune = 20013 or 0x4e2d
assert_eq!(true, bytes::ContainsRune("hello中国!".as_bytes(), 20013));
assert_eq!(true, bytes::ContainsRune("hello中国!".to_string(), 0x4e2d));
assert_eq!(true, bytes::ContainsRune("hello中国!", 0x4e2d));
assert_eq!(false, bytes::ContainsRune("hello世界!", 0x4e2d));