Closed TianyiShi2001 closed 4 years ago
implementing an AnyTag struct, e,g.
AnyTag
pub struct AnyTag { pub title: Option<String>, pub artists: Option<Vec<String>>, pub year: Option<i32>, pub album_title: Option<String>, pub album_artists: Option<Vec<String>>, pub album_cover: Option<Picture>, pub track_number: Option<u16>, pub total_tracks: Option<u16>, pub disc_number: Option<u16>, pub total_discs: Option<u16>, ... }
and corresponding From traits for different specific tag formats will allow conversions between them.
From
The challenge is: can this be implemented without copying (cloning)? i.e. can the above be implemented as:
pub struct AnyTag1<'a> { pub title: Option<&'a str>, pub artists: Option<Vec<&'a str>>, pub year: Option<i32>, pub album_title: Option<&'a str>, pub album_artists: Option<Vec<&'a str>>, pub album_cover: Option<&'a Picture>, pub track_number: Option<u16>, pub total_tracks: Option<u16>, pub disc_number: Option<u16>, pub total_discs: Option<u16>, }
Currently I'm using beef::lean::Cow to do this. Is this necessary?
beef::lean::Cow
implementing an
AnyTag
struct, e,g.and corresponding
From
traits for different specific tag formats will allow conversions between them.The challenge is: can this be implemented without copying (cloning)? i.e. can the above be implemented as: