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 9103bd5 commit dbaad4fCopy full SHA for dbaad4f
crates/formality-core/src/collections.rs
@@ -75,6 +75,8 @@ pub trait SetExt<T>: Sized {
75
fn union_with(self, other: Self) -> Self;
76
77
fn plus(self, other: T) -> Self;
78
+
79
+ fn split_nth(&self, i: usize) -> Option<(T, Self)>;
80
}
81
82
impl<T: Ord + Clone> SetExt<T> for Set<T> {
@@ -85,6 +87,13 @@ impl<T: Ord + Clone> SetExt<T> for Set<T> {
85
87
Some((e, c))
86
88
89
90
+ fn split_nth(&self, i: usize) -> Option<(T, Self)> {
91
+ let mut s = self.clone();
92
+ let item = self.iter().skip(i).next()?;
93
+ let item = s.take(item).unwrap();
94
+ Some((item, s))
95
+ }
96
97
fn union_with(mut self, other: Self) -> Self {
98
for item in other {
99
self.insert(item);
0 commit comments