We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a32ee7 commit da19563Copy full SHA for da19563
src/libstd/vec_ng.rs
@@ -64,6 +64,26 @@ impl<T> Vec<T> {
64
xs
65
}
66
67
+
68
+ /**
69
+ * Partitions the vector into two vectors `(A,B)`, where all
70
+ * elements of `A` satisfy `f` and all elements of `B` do not.
71
+ */
72
+ #[inline]
73
+ pub fn partition(self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
74
+ let mut lefts = Vec::new();
75
+ let mut rights = Vec::new();
76
77
+ for elt in self.move_iter() {
78
+ if f(&elt) {
79
+ lefts.push(elt);
80
+ } else {
81
+ rights.push(elt);
82
+ }
83
84
85
+ (lefts, rights)
86
87
88
89
impl<T: Clone> Vec<T> {
0 commit comments