mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-30 16:30:49 +08:00
git-trailers: improve usage of OwnedTrailer
OwnedTrailer was lacking a Debug impl and access to its values. Add a Debug derivation for OwnedTrailer and OwnedToken. Make token and values public. Add Deref implementation for OwnedToken. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
+12
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user