summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-10-16 11:28:19 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-10-16 11:28:19 +0200
commit30825a1450447ca9584b1251493c1362f24cd861 (patch)
tree9c9ca7b1c67b220b51e5aaaa5f710b605a1ed4dc
parent405154a3947a7ceb9f381c382340f7f44497160f (diff)
parent7148d577e84cad67e9c3ddc426df56d8a60be7c1 (diff)
Merge branch 'dedicated-error-mod'
-rw-r--r--src/btreemap.rs11
-rw-r--r--src/error.rs13
-rw-r--r--src/hashmap.rs11
-rw-r--r--src/lib.rs3
4 files changed, 18 insertions, 20 deletions
diff --git a/src/btreemap.rs b/src/btreemap.rs
index 2ada9aa..77a0651 100644
--- a/src/btreemap.rs
+++ b/src/btreemap.rs
@@ -5,16 +5,7 @@ use std::hash::Hash;
use std::iter::FromIterator;
use std::iter::IntoIterator;
-#[derive(Debug, thiserror::Error)]
-pub enum Error<K>
- where K: Debug,
-{
- #[error("duplicated key in iterator: {:?}", _0)]
- DuplicatedKey(K),
-
- #[error("unknown error")]
- Unknown,
-}
+use crate::error::Error;
pub struct CollectOnceBTreeMap<K, V>
where K: Eq + Ord + Hash + Debug
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..8a9a173
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,13 @@
+use std::fmt::Debug;
+
+#[derive(Debug, thiserror::Error)]
+pub enum Error<K>
+ where K: Debug,
+{
+ #[error("duplicated key in iterator: {:?}", _0)]
+ DuplicatedKey(K),
+
+ #[error("unknown error")]
+ Unknown,
+}
+
diff --git a/src/hashmap.rs b/src/hashmap.rs
index ebb6321..4095f15 100644
--- a/src/hashmap.rs
+++ b/src/hashmap.rs
@@ -10,16 +10,7 @@ use std::iter::FromIterator;
use std::iter::IntoIterator;
use std::collections::HashMap;
-#[derive(Debug, thiserror::Error)]
-pub enum Error<K>
- where K: Debug,
-{
- #[error("duplicated key in iterator: {:?}", _0)]
- DuplicatedKey(K),
-
- #[error("unknown error")]
- Unknown,
-}
+use crate::error::Error;
pub struct CollectOnceHashMap<K, V, S = std::collections::hash_map::RandomState>
where K: Eq + Hash + Debug
diff --git a/src/lib.rs b/src/lib.rs
index f669f75..ff916b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,9 @@
#![doc = include_str!("../README.md")]
+mod error;
+pub use error::*;
+
mod hashmap;
pub use hashmap::*;