1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 20:17:45 +00:00

tsort: use iterators to remove from vec

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
jfinkels 2025-01-11 11:47:23 -05:00 committed by GitHub
parent af99952de6
commit 700a5f007a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,13 +105,10 @@ fn remove<T>(vec: &mut Vec<T>, x: T) -> Option<usize>
where where
T: PartialEq, T: PartialEq,
{ {
for i in 0..vec.len() { vec.iter().position(|item| *item == x).map(|i| {
if vec[i] == x { vec.remove(i);
vec.remove(i); i
return Some(i); })
}
}
None
} }
// We use String as a representation of node here // We use String as a representation of node here