mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-30 11:32:04 +03:00
Merge pull request #4650 from gitbutlerapp/add-reference-name-struct
derive some useful traits for tagged string and reference name
This commit is contained in:
commit
ee7660f395
@ -26,6 +26,7 @@ pub fn normalize_branch_name(name: &str) -> anyhow::Result<String> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct _ReferenceName;
|
||||
/// The name of a reference i.e. `refs/heads/master`
|
||||
pub type ReferenceName = TaggedString<_ReferenceName>;
|
||||
|
@ -3,6 +3,7 @@ use std::{fmt, marker::PhantomData, ops::Deref};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// Tagged string is designed to clarify the purpose of strings when used as a return type
|
||||
#[derive(Default, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TaggedString<T>(String, PhantomData<T>);
|
||||
|
||||
impl<T> From<String> for TaggedString<T> {
|
||||
|
Loading…
Reference in New Issue
Block a user