Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: try_fold + into_iter use
Fintan Halpenny committed 22 days ago
commit d57c76c557aabc23ad112b07483e6339a4508689
parent 5f8bb171656910d488c9455b751681f322c45a30
1 file changed +5 -5
modified crates/radicle/src/git/canonical/symbolic.rs
@@ -201,11 +201,11 @@ impl TryFrom<IndexMap<Name, Target>> for SymbolicRefs {
    type Error = InsertionError;

    fn try_from(map: IndexMap<Name, Target>) -> Result<Self, Self::Error> {
-
        let mut result = Self::default();
-
        for (name, target) in map.iter() {
-
            result.try_insert_unprotected(name.clone(), target.clone())?;
-
        }
-
        Ok(result)
+
        map.into_iter()
+
            .try_fold(Self::default(), |mut result, (name, target)| {
+
                result.try_insert_unprotected(name, target)?;
+
                Ok(result)
+
            })
    }
}