Refactor using `NonEmpty::try_map`

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-12-12 15:10:06 +01:00
parent f90f714fcf
commit 909b99bb7c
No known key found for this signature in database
3 changed files with 4 additions and 16 deletions

View File

@ -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,

View File

@ -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))
}

View File

@ -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,