You can also avoid unnecessary distributions Vecif you need to use only the first or second part:
fn split<'a>(slice: &'a [u8], splitter: &[u8]) -> Option<&'a [u8]> {
let mut parts = slice.split(|b| splitter.contains(b)).fuse();
let first = parts.next();
let second = parts.next();
second.or(first)
}
Then, if you really need to Vec, you can match the result:
split(&[1u8, 2u8, 3u8], &[2u8]).map(|s| s.to_vec())
Of course, if you want, you can move the conversion to_vec()to a function:
second.or(first).map(|s| s.to_vec())
I call fuse()on the iterator to ensure that it will always return Noneafter the first None(which is not guaranteed by the general iterator protocol).