From 909b99bb7cab6bc56ba3e120cc1630e1b40295aa Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 12 Dec 2022 15:10:06 +0100 Subject: [PATCH] Refactor using `NonEmpty::try_map` Signed-off-by: Alexis Sellier --- radicle/src/cob/issue.rs | 2 +- radicle/src/cob/patch.rs | 2 +- radicle/src/cob/store.rs | 16 ++-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index b3a049f2..6dc811f2 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -396,7 +396,7 @@ impl<'a> Issues<'a> { tx.tag(tags.to_owned(), []); })?; // Just a sanity check that our clock is advancing as expected. - assert_eq!(clock.get(), 2); + debug_assert_eq!(clock.get(), 2); Ok(IssueMut { id, diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 9e186b40..e8ea5fd2 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -769,7 +769,7 @@ impl<'a> Patches<'a> { tx.tag(tags.to_owned(), []); })?; // Just a sanity check that our clock is advancing as expected. - assert_eq!(clock.get(), 2); + debug_assert_eq!(clock.get(), 2); Ok(PatchMut::new(id, patch, clock, self)) } diff --git a/radicle/src/cob/store.rs b/radicle/src/cob/store.rs index 0d4e90a4..81c71f3d 100644 --- a/radicle/src/cob/store.rs +++ b/radicle/src/cob/store.rs @@ -104,13 +104,7 @@ where actions: impl Into>, signer: &G, ) -> Result { - let changes = actions - .into() - .iter() - .map(encoding::encode) - .collect::, _>>()? - .try_into() - .expect("the collection is always non-empty"); + let changes = actions.into().try_map(|e| encoding::encode(&e))?; cob::update( self.raw, @@ -135,13 +129,7 @@ where actions: impl Into>, signer: &G, ) -> Result<(ObjectId, T, Lamport), Error> { - let contents = actions - .into() - .iter() - .map(encoding::encode) - .collect::, _>>()? - .try_into() - .expect("the collection is always non-empty"); + let contents = actions.into().try_map(|e| encoding::encode(&e))?; let cob = cob::create( self.raw, signer,