index buffer: add FromIterator trait

This commit is contained in:
Michael Sippel 2023-08-14 01:20:43 +02:00
parent 930759d2a1
commit f263968d35
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 13 additions and 2 deletions

View file

@ -6,7 +6,7 @@ use {
}, },
}, },
std::sync::RwLock, std::sync::RwLock,
std::{collections::HashMap, hash::Hash, sync::Arc, ops::{Deref, DerefMut}}, std::{iter::FromIterator, collections::HashMap, hash::Hash, sync::Arc, ops::{Deref, DerefMut}},
}; };
pub struct IndexBufferView<Key, Item>(Arc<RwLock<HashMap<Key, Item>>>) pub struct IndexBufferView<Key, Item>(Arc<RwLock<HashMap<Key, Item>>>)
@ -48,6 +48,18 @@ where
port: InnerViewPort<dyn IndexView<Key, Item = Item>>, port: InnerViewPort<dyn IndexView<Key, Item = Item>>,
} }
impl<Key, Item> FromIterator<(Key, Item)> for IndexBuffer<Key, Item>
where Key: Send+Sync+Clone+Eq+Hash,
Item: Send+Sync+Clone
{
fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = (Key, Item)> {
let mut buf = IndexBuffer::new();
buf.insert_iter(iter);
buf
}
}
impl<Key, Item> IndexBuffer<Key, Item> impl<Key, Item> IndexBuffer<Key, Item>
where where
Key: Clone + Hash + Eq + Send + Sync + 'static, Key: Clone + Hash + Eq + Send + Sync + 'static,

View file

@ -1 +0,0 @@