如何基于分隔符将向量分割为切片的向量?

问题描述 投票:1回答:1

[如果我有矢量,例如

let mut bytes = vec![0x01, 0x02, 0x03, 0x40, 0x04, 0x05, 0x40, 0x06, 0x40];

我想用0x40分隔符分隔向量。有没有一种干净的方法可以执行此功能?

预期输出:[[0x01, 0x02, 0x03], [0x04, 0x05], [0x06]]

rust
1个回答
0
投票

使用slice::split

slice::split
© www.soinside.com 2019 - 2024. All rights reserved.