Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2dea70a

Browse files
[Result migration] Return Result from PushUpdate methods
* `PushUpdate::src_refname()` * `PushUpdate::dst_refname()`
1 parent c504587 commit 2dea70a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/push_update.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::util::Binding;
2-
use crate::{raw, Oid};
2+
use crate::{raw, Error, Oid};
33
use std::marker;
44
use std::str;
55

@@ -28,19 +28,19 @@ impl PushUpdate<'_> {
2828
unsafe { crate::opt_bytes(self, (*self.raw).src_refname).unwrap() }
2929
}
3030

31-
/// Returns the source name of the reference, or None if it is not valid UTF-8.
32-
pub fn src_refname(&self) -> Option<&str> {
33-
str::from_utf8(self.src_refname_bytes()).ok()
31+
/// Returns the source name of the reference.
32+
pub fn src_refname(&self) -> Result<&str, Error> {
33+
str::from_utf8(self.src_refname_bytes()).map_err(|e| e.into())
3434
}
3535

3636
/// Returns the name of the reference to update on the server as a byte slice.
3737
pub fn dst_refname_bytes(&self) -> &[u8] {
3838
unsafe { crate::opt_bytes(self, (*self.raw).dst_refname).unwrap() }
3939
}
4040

41-
/// Returns the name of the reference to update on the server, or None if it is not valid UTF-8.
42-
pub fn dst_refname(&self) -> Option<&str> {
43-
str::from_utf8(self.dst_refname_bytes()).ok()
41+
/// Returns the name of the reference to update on the server.
42+
pub fn dst_refname(&self) -> Result<&str, Error> {
43+
str::from_utf8(self.dst_refname_bytes()).map_err(|e| e.into())
4444
}
4545

4646
/// Returns the current target of the reference.

0 commit comments

Comments
 (0)