-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
The split method consumes the element used to split, how you can see in the code below. But in some cases would be nice to move the element to the "first or second slice" like the split_at method does, but to n slices.
The numpy library has a method like that.
Code
#[derive(Clone, Debug)]
struct Delta {
pub val: i32
}
fn main() {
let mut v = vec![Delta{ val: 1 }, Delta{ val: 5 }, Delta{ val: 1 }];
let new_v : Vec<Vec<Delta>> = v.split(|x| x.val > 4)
.into_iter()
.map(|x| x.to_vec())
.collect();
println!("{:?}", new_v);
}
Output
[[Delta { val: 1 }], [Delta { val: 1 }]]
New Split Method1 Output
[[Delta { val: 1 }, Delta { val: 5 }], [Delta { val: 1 }]]
New Split Method2 Output
[[Delta { val: 1 }], [Delta { val: 5 }, Delta { val: 1 }]]
henrique07santana, eduwillrich, manoelstilpen, F-Amaral, VitoriaLinda and 9 more
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.