Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Refactor using `NonEmpty::try_map`
Alexis Sellier committed 3 years ago
commit 909b99bb7cab6bc56ba3e120cc1630e1b40295aa
parent f90f714fcfbe15f82416aaff04472d36919b73dd
3 files changed +4 -16
modified 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,
modified 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))
    }
modified radicle/src/cob/store.rs
@@ -104,13 +104,7 @@ where
        actions: impl Into<NonEmpty<T::Action>>,
        signer: &G,
    ) -> Result<CollaborativeObject, Error> {
-
        let changes = actions
-
            .into()
-
            .iter()
-
            .map(encoding::encode)
-
            .collect::<Result<Vec<_>, _>>()?
-
            .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<NonEmpty<T::Action>>,
        signer: &G,
    ) -> Result<(ObjectId, T, Lamport), Error> {
-
        let contents = actions
-
            .into()
-
            .iter()
-
            .map(encoding::encode)
-
            .collect::<Result<Vec<_>, _>>()?
-
            .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,