From 579902ceb5d9ec9d3d8c98a06faf8e9024aac5bd Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 30 Jun 2021 00:53:16 -0400 Subject: [PATCH] Revert changes made in lofty-attr Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com> --- lofty-attr/Cargo.lock | 2 +- lofty-attr/Cargo.toml | 2 +- lofty-attr/src/lib.rs | 80 +++++++++++++++++++------------------------ 3 files changed, 37 insertions(+), 47 deletions(-) diff --git a/lofty-attr/Cargo.lock b/lofty-attr/Cargo.lock index ac0c5717..396ae420 100644 --- a/lofty-attr/Cargo.lock +++ b/lofty-attr/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "lofty_attr" -version = "0.1.3" +version = "0.1.4" dependencies = [ "quote", "syn", diff --git a/lofty-attr/Cargo.toml b/lofty-attr/Cargo.toml index 887cfdfc..847fe3b8 100644 --- a/lofty-attr/Cargo.toml +++ b/lofty-attr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lofty_attr" -version = "0.1.3" +version = "0.1.4" authors = ["Serial <69764315+Serial-ATA@users.noreply.github.com>"] description = "Macro for Lofty tag struct creation" license = "MIT OR Apache-2.0" diff --git a/lofty-attr/src/lib.rs b/lofty-attr/src/lib.rs index 33d91b1a..78a84473 100644 --- a/lofty-attr/src/lib.rs +++ b/lofty-attr/src/lib.rs @@ -23,50 +23,6 @@ pub fn impl_tag(args: TokenStream, input: TokenStream) -> TokenStream { if let Some(inner) = inner.get_ident() { let input_ident = input.ident; - let mut anytag_convert = quote! { - impl<'a> From> for #input_ident { - fn from(inp: AnyTag<'a>) -> Self { - let mut tag = #input_ident::default(); - - if let Some(v) = inp.title() { - tag.set_title(v) - } - if let Some(v) = inp.artists_as_string() { - tag.set_artist(&v) - } - if let Some(v) = inp.year { - tag.set_year(v) - } - if let Some(v) = inp.album().title { - tag.set_album_title(v) - } - if let Some(v) = inp.album().artists { - tag.set_album_artist(&v.join("/")) - } - if let Some(v) = inp.track_number() { - tag.set_track_number(v) - } - if let Some(v) = inp.total_tracks() { - tag.set_total_tracks(v) - } - if let Some(v) = inp.disc_number() { - tag.set_disc_number(v) - } - if let Some(v) = inp.total_discs() { - tag.set_total_discs(v) - } - - tag - } - } - }; - - if let Some(attr) = input.attrs.first() { - if attr.path.is_ident("custom_convert") { - anytag_convert = quote! {}; - } - } - let expanded = quote! { #[doc(hidden)] pub struct #input_ident { @@ -146,7 +102,41 @@ pub fn impl_tag(args: TokenStream, input: TokenStream) -> TokenStream { } } - #anytag_convert + impl<'a> From> for #input_ident { + fn from(inp: AnyTag<'a>) -> Self { + let mut tag = #input_ident::default(); + + if let Some(v) = inp.title() { + tag.set_title(v) + } + if let Some(v) = inp.artists_as_string() { + tag.set_artist(&v) + } + if let Some(v) = inp.year { + tag.set_year(v) + } + if let Some(v) = inp.album().title { + tag.set_album_title(v) + } + if let Some(v) = inp.album().artists { + tag.set_album_artist(&v.join("/")) + } + if let Some(v) = inp.track_number() { + tag.set_track_number(v) + } + if let Some(v) = inp.total_tracks() { + tag.set_total_tracks(v) + } + if let Some(v) = inp.disc_number() { + tag.set_disc_number(v) + } + if let Some(v) = inp.total_discs() { + tag.set_total_discs(v) + } + + tag + } + } // From dyn AudioTag to wrapper (any type) impl From> for #input_ident {