From efdc8c52c77fa6d3afbc602b9334a8f11cedf77f Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 3 Oct 2022 21:33:04 +0200 Subject: [PATCH] Add a `CommitObject::TryFrom` instance Signed-off-by: Alexis Sellier --- radicle/src/git.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/radicle/src/git.rs b/radicle/src/git.rs index 02e99b60..fca7f7e8 100644 --- a/radicle/src/git.rs +++ b/radicle/src/git.rs @@ -323,6 +323,14 @@ pub mod commit { InvalidFormat, } + impl TryFrom for CommitObject { + type Error = ParseError; + + fn try_from(value: git2::Buf) -> Result { + value.as_str().ok_or(ParseError::InvalidFormat)?.parse() + } + } + impl FromStr for CommitObject { type Err = ParseError;