LastIndexByte

Function LastIndexByte 

Source
pub fn LastIndexByte(s: impl AsRef<[byte]>, c: byte) -> int
Expand description

LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.

zh-cn 返回s中c的最后一个出现的位置,如果s中不存在c,则返回-1。

§Example

use gostd_bytes as bytes;

assert_eq!(10,bytes::LastIndexByte("Hello, world", b'l'));
assert_eq!(8,bytes::LastIndexByte("Hello, world", b'o'));
assert_eq!(10,bytes::LastIndexByte("Hello, world".as_bytes(), b'l'));
assert_eq!(8,bytes::LastIndexByte(vec!['H','e','l','l','o',',',' ','w','o','r','l','d'].iter().map(|c| *c as u8).collect::<Vec<_>>(), b'o'));
assert_eq!(-1,bytes::LastIndexByte("Hello, world", b'x'));