Impl IntoIterator for &Records

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-27 22:22:07 +10:00
parent df3af9727e
commit aba2c87d6d
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -1,9 +1,9 @@
use std::{ use std::{
cmp, cmp,
collections::BTreeSet, collections::{btree_set, BTreeSet},
fs, hash, fs, hash,
io::{self, Write}, io::{self, Write},
iter::IntoIterator, iter::{IntoIterator, Iterator},
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
@ -155,3 +155,13 @@ impl Records {
write_to(self.file, &mut self.data.into_iter()) write_to(self.file, &mut self.data.into_iter())
} }
} }
impl<'a> IntoIterator for &'a Records {
type Item = &'a MetaData;
type IntoIter = btree_set::Iter<'a, MetaData>;
fn into_iter(self) -> Self::IntoIter {
self.data.iter()
}
}