diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-12-28 16:14:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-28 16:14:27 +0000 |
commit | 1ae9cf9eb463f9fdcd5b843f3a6e979a72258e4d (patch) | |
tree | 56075181ade1b6514f80d5f336d05a1821912e0e /src/test_impl.rs | |
parent | cb1f23e1126b6f097906729e6b775499f55a07df (diff) | |
parent | 7863c3bcf8c7ca37bfc5652ec92e620968e635e4 (diff) |
Merge #3
3: Transform codebase to use thiserror r=matthiasbeyer a=matthiasbeyer
Co-authored-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/test_impl.rs')
-rw-r--r-- | src/test_impl.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/test_impl.rs b/src/test_impl.rs index a95c4c6..c8f2b51 100644 --- a/src/test_impl.rs +++ b/src/test_impl.rs @@ -7,9 +7,20 @@ use std::sync::Arc; use std::sync::RwLock; -use anyhow::Result; use async_trait::async_trait; +#[derive(Debug)] +pub struct TestError; + +impl<Id> From<crate::Error<Id>> for TestError +where + Id: crate::NodeId, +{ + fn from(_ce: crate::Error<Id>) -> Self { + TestError + } +} + #[derive(Copy, Clone, Eq, PartialEq, std::hash::Hash, Debug)] pub struct Id(pub(crate) usize); @@ -46,7 +57,9 @@ impl Backend { #[async_trait] impl crate::DagBackend<Id, Node> for Backend { - async fn get(&self, id: Id) -> Result<Option<(Id, Node)>> { + type Error = TestError; + + async fn get(&self, id: Id) -> Result<Option<(Id, Node)>, Self::Error> { if self.0.read().unwrap().len() < id.0 + 1 { Ok(None) } else { @@ -54,7 +67,7 @@ impl crate::DagBackend<Id, Node> for Backend { } } - async fn put(&mut self, node: Node) -> Result<Id> { + async fn put(&mut self, node: Node) -> Result<Id, Self::Error> { while self.0.read().unwrap().len() < node.data + 1 { self.0.write().unwrap().push(None) } |