index buffer: add FromIterator trait
This commit is contained in:
parent
930759d2a1
commit
f263968d35
2 changed files with 13 additions and 2 deletions
|
@ -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,
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
Loading…
Reference in a new issue