melib/backends.rs: impl Into<BTreeSet<EnvelopeHash>> for EnvelopeHashBatch

issue-133
Manos Pitsidianakis 2022-09-18 01:42:45 +03:00
parent a7a50d3078
commit b87d54ea3f
1 changed files with 10 additions and 0 deletions

View File

@ -663,6 +663,12 @@ impl std::convert::TryFrom<&[EnvelopeHash]> for EnvelopeHashBatch {
}
}
impl Into<BTreeSet<EnvelopeHash>> for &EnvelopeHashBatch {
fn into(self) -> BTreeSet<EnvelopeHash> {
self.iter().collect::<BTreeSet<EnvelopeHash>>()
}
}
impl EnvelopeHashBatch {
pub fn iter(&self) -> impl std::iter::Iterator<Item = EnvelopeHash> + '_ {
std::iter::once(self.first).chain(self.rest.iter().cloned())
@ -671,6 +677,10 @@ impl EnvelopeHashBatch {
pub fn len(&self) -> usize {
1 + self.rest.len()
}
pub fn to_set(&self) -> BTreeSet<EnvelopeHash> {
self.into()
}
}
#[derive(Default, Clone)]