Radish alpha
r
Git libraries for Radicle
Radicle
Git (anonymous pull)
Log in to clone via SSH
git-trailers: improve usage of OwnedTrailer
Fintan Halpenny committed 3 years ago
commit ddbdbea93220c5a190a629b069d112da99b6510d
parent ea0afc49935906376860d65c60faa8c11e278869
1 file changed +12 -2
modified git-trailers/src/lib.rs
@@ -45,11 +45,13 @@ pub struct Token<'a>(&'a str);

/// A version of the Trailer<'a> which owns it's token and values. Useful for
/// when you need to carry trailers around in a long lived data structure.
+
#[derive(Debug)]
pub struct OwnedTrailer {
-
    token: OwnedToken,
-
    values: Vec<String>,
+
    pub token: OwnedToken,
+
    pub values: Vec<String>,
}

+
#[derive(Debug)]
pub struct OwnedToken(String);

impl<'a> From<&Trailer<'a>> for OwnedTrailer {
@@ -76,6 +78,14 @@ impl<'a> From<&'a OwnedTrailer> for Trailer<'a> {
    }
}

+
impl Deref for OwnedToken {
+
    type Target = str;
+

+
    fn deref(&self) -> &Self::Target {
+
        &self.0
+
    }
+
}
+

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum InvalidToken {