From f263968d35397fffe24eb8243464b01e37658680 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 14 Aug 2023 01:20:43 +0200 Subject: [PATCH] index buffer: add FromIterator trait --- src/buffer/index_hashmap.rs | 14 +++++++++++++- src/view/view.rs | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) delete mode 100644 src/view/view.rs diff --git a/src/buffer/index_hashmap.rs b/src/buffer/index_hashmap.rs index 72b0625..8ca9a44 100644 --- a/src/buffer/index_hashmap.rs +++ b/src/buffer/index_hashmap.rs @@ -6,7 +6,7 @@ use { }, }, 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(Arc>>) @@ -48,6 +48,18 @@ where port: InnerViewPort>, } +impl FromIterator<(Key, Item)> for IndexBuffer +where Key: Send+Sync+Clone+Eq+Hash, + Item: Send+Sync+Clone +{ + fn from_iter(iter: T) -> Self + where T: IntoIterator { + let mut buf = IndexBuffer::new(); + buf.insert_iter(iter); + buf + } +} + impl IndexBuffer where Key: Clone + Hash + Eq + Send + Sync + 'static, diff --git a/src/view/view.rs b/src/view/view.rs deleted file mode 100644 index 8b13789..0000000 --- a/src/view/view.rs +++ /dev/null @@ -1 +0,0 @@ -