pub fn LastIndex(s: impl AsRef<[byte]>, sep: impl AsRef<[byte]>) -> intExpand description
LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
zh-cn
切片sep在字符串s中最后一次出现的位置,不存在则返回-1。§Example
use gostd_bytes as bytes;
assert_eq!(4,bytes::Index("rust社区 rust社区acean","社区"));
assert_eq!(15,bytes::LastIndex("rust社区 rust社区acean","社区"));
assert_eq!(4,bytes::Index("rust社区 rust社区acean".to_string(),"社区".to_string()));
assert_eq!(15,bytes::LastIndex("rust社区 rust社区acean".as_bytes(),"社区".as_bytes()));
assert_eq!(5,bytes::LastIndex("rust rustacean","rust"));
assert_eq!(-1,bytes::LastIndex("rust rustacean","go"));
// 以下例子只适用于ASCII字符串
assert_eq!(0,bytes::Index(b"rust rustacean",b"rust"));
assert_eq!(5,bytes::LastIndex(b"rust rustacean",b"rust"));
assert_eq!(-1,bytes::LastIndex(b"rust rustacean",b"go"));