Cut

Function Cut 

Source
pub fn Cut<'a>(s: &'a [byte], sep: &[byte]) -> (&'a [byte], &'a [byte], bool)
Expand description

Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, “”, false.

zh-cn 在s中的第一个分隔sep处切分子切片,返回sep前面部分子切片before和sep后面的部分切片after。found 值表示在s字符串中是否找到sep字节切片。如果seq在s中找不到,切割结果返回(s,"",false)。

§Example

use gostd_bytes as bytes;

assert_eq!(bytes::Cut("127.0.0.1:8080".as_bytes(),":".as_bytes()),(b"127.0.0.1".as_slice(),b"8080".as_slice(),true));