Skip to content

Commit 8a27454

Browse files
committedAug 8, 2024··
feat: remote::Name::to_owned() to get a static version of it.
Also, add optional `serde` support.
1 parent b0668fb commit 8a27454

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

Diff for: ‎gix/src/remote/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl Direction {
2323

2424
/// The name of a remote, either interpreted as symbol like `origin` or as url as returned by [`Remote::name()`][crate::Remote::name()].
2525
#[derive(Debug, PartialEq, Eq, Clone, Ord, PartialOrd, Hash)]
26+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2627
pub enum Name<'repo> {
2728
/// A symbolic name, like `origin`.
2829
/// Note that it has not necessarily been validated yet.

Diff for: ‎gix/src/remote/name.rs

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ impl Name<'_> {
5050
Name::Symbol(_) => None,
5151
}
5252
}
53+
54+
/// Return a fully-owned copy of this instance.
55+
pub fn to_owned(&self) -> Name<'static> {
56+
match self {
57+
Name::Symbol(s) => Name::Symbol(s.clone().into_owned().into()),
58+
Name::Url(s) => Name::Url(s.clone().into_owned().into()),
59+
}
60+
}
5361
}
5462

5563
impl<'a> TryFrom<Cow<'a, BStr>> for Name<'a> {

0 commit comments

Comments
 (0)
Please sign in to comment.