diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-10-16 11:28:19 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-10-16 11:28:19 +0200 |
commit | 30825a1450447ca9584b1251493c1362f24cd861 (patch) | |
tree | 9c9ca7b1c67b220b51e5aaaa5f710b605a1ed4dc | |
parent | 405154a3947a7ceb9f381c382340f7f44497160f (diff) | |
parent | 7148d577e84cad67e9c3ddc426df56d8a60be7c1 (diff) |
Merge branch 'dedicated-error-mod'
-rw-r--r-- | src/btreemap.rs | 11 | ||||
-rw-r--r-- | src/error.rs | 13 | ||||
-rw-r--r-- | src/hashmap.rs | 11 | ||||
-rw-r--r-- | src/lib.rs | 3 |
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 @@ -6,6 +6,9 @@ #![doc = include_str!("../README.md")] +mod error; +pub use error::*; + mod hashmap; pub use hashmap::*; |