From ddbdbea93220c5a190a629b069d112da99b6510d Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 27 Oct 2022 11:44:20 +0100 Subject: [PATCH 1/2] 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 X-Clacks-Overhead: GNU Terry Pratchett --- git-trailers/src/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git-trailers/src/lib.rs b/git-trailers/src/lib.rs index d14dbf6..b982396 100644 --- a/git-trailers/src/lib.rs +++ b/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, + pub token: OwnedToken, + pub values: Vec, } +#[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 { From c6fe71d2e572d2954b9daf87020d9a3960f5e679 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 27 Oct 2022 12:03:54 +0100 Subject: [PATCH 2/2] git-trailers: prepare git-trailers for publishing Prepares git-trailers for publishing to crates.io by adding metadata to the Cargo.toml. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- git-trailers/Cargo.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git-trailers/Cargo.toml b/git-trailers/Cargo.toml index 937553a..7316b8b 100644 --- a/git-trailers/Cargo.toml +++ b/git-trailers/Cargo.toml @@ -1,9 +1,15 @@ [package] name = "git-trailers" version = "0.1.0" -authors = ["Nuno Alexandre ", "Kim Altintop "] +authors = [ + "Nuno Alexandre ", + "Kim Altintop ", + "Fintan Halpenny ", +] edition = "2018" license = "GPL-3.0-or-later" +description = "Library to support parsing and display git trailers " +keywords = ["git"] [lib] doctest = false