prevent clone

This commit is contained in:
Tianyi 2020-10-27 12:01:15 +00:00
parent f2c743d81e
commit d4af2dcb03
6 changed files with 12 additions and 15 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "audiotags"
version = "0.2.5"
version = "0.2.6"
authors = ["Tianyi <ShiTianyi2001@outlook.com>"]
edition = "2018"
description = "Unified IO for different types of audio metadata"
@ -15,4 +15,4 @@ mp4ameta = "0.6"
metaflac = "0.2"
beef = "0.4.4"
thiserror = "1.0.21"
audiotags-dev-macro = "0.1.0"
audiotags-dev-macro = {path = "./audiotags-dev-macro", version = "0.1.1"}

View file

@ -100,9 +100,9 @@ fn main() {
Some(vec!["artist1 of mp4", "artist2 of mp4"])
);
// convert to id3 tag, which does not support multiple artists
let mp3tag = mp4tag
.with_config(Config::default().sep_artist("/")) // separator is by default `;`
.into_tag(TagType::Id3v2);
mp4tag.set_config(Config::default().sep_artist("/"));
// separator is by default `;` but we can customise it
let mp3tag = mp4tag.into_tag(TagType::Id3v2);
assert_eq!(mp3tag.artist(), Some("artist1 of mp4/artist2 of mp4"));
}
```

View file

@ -1,6 +1,6 @@
[package]
name = "audiotags-dev-macro"
version = "0.1.0"
version = "0.1.1"
authors = ["Tianyi <ShiTianyi2001@outlook.com>"]
edition = "2018"
description = "macros used during the development of audiotags"

View file

@ -21,11 +21,8 @@ macro_rules! impl_tag {
fn config(&self) -> &Config {
&self.config
}
fn with_config(&self, config: Config) -> Box<dyn AudioTag> {
Box::new(Self {
inner: self.inner.clone(),
config,
})
fn set_config(&mut self, config: Config) {
self.config = config.clone();
}
fn into_anytag(&self) -> AnyTag<'_> {
self.into()

View file

@ -539,7 +539,7 @@ pub trait AudioTag: AudioTagCommon {
pub trait AudioTagCommon {
fn config(&self) -> &Config;
fn with_config(&self, config: Config) -> Box<dyn AudioTag>;
fn set_config(&mut self, config: Config);
fn into_anytag(&self) -> AnyTag<'_>;
/// Convert the tag type, which can be lossy.

View file

@ -27,8 +27,8 @@ fn test_convert_mp3_to_mp4() {
Some(vec!["artist1 of mp4", "artist2 of mp4"])
);
// convert to id3 tag, which does not support multiple artists
let mp3tag = mp4tag
.with_config(Config::default().sep_artist("/")) // separator is by default `;`
.into_tag(TagType::Id3v2);
mp4tag.set_config(Config::default().sep_artist("/"));
// separator is by default `;` but we can customise it
let mp3tag = mp4tag.into_tag(TagType::Id3v2);
assert_eq!(mp3tag.artist(), Some("artist1 of mp4/artist2 of mp4"));
}