Skip to content

Commit 76a7429

Browse files
squellbjorn3
authored andcommitted
make VecOrd a newtype
1 parent 2c31110 commit 76a7429

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/sudoers/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,18 @@ pub(super) struct AliasTable {
273273
}
274274

275275
/// A vector with a list defining the order in which it needs to be processed
276-
type VecOrd<T> = (Vec<usize>, Vec<T>);
276+
struct VecOrd<T>(Vec<usize>, Vec<T>);
277277

278-
fn elems<T>(vec: &VecOrd<T>) -> impl Iterator<Item = &T> {
279-
vec.0.iter().map(|&i| &vec.1[i])
278+
impl<T> Default for VecOrd<T> {
279+
fn default() -> Self {
280+
VecOrd(Vec::default(), Vec::default())
281+
}
282+
}
283+
284+
impl<T> VecOrd<T> {
285+
fn iter(&self) -> impl Iterator<Item = &T> {
286+
self.0.iter().map(|&i| &self.1[i])
287+
}
280288
}
281289

282290
/// Check if the user `am_user` is allowed to run `cmdline` on machine `on_host` as the requested
@@ -481,7 +489,7 @@ where
481489
let all = Qualified::Allow(Meta::All);
482490

483491
let mut set = HashMap::new();
484-
for Def(id, list) in elems(table) {
492+
for Def(id, list) in table.iter() {
485493
if find_item(list, &pred, &set).is_some() {
486494
set.insert(id.clone(), true);
487495
} else if find_item(once(&all).chain(list), &pred, &set).is_none() {

0 commit comments

Comments
 (0)