mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
Rename VorbisComments::remove_key
, make it return an iterator
This commit is contained in:
parent
afd1a6d8ef
commit
065c70b176
2 changed files with 16 additions and 5 deletions
|
@ -36,7 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- **MP4**: Renamed `AdvisoryRating::None` to `AdvisoryRating::Inoffensive`
|
- **MP4**: Renamed `AdvisoryRating::None` to `AdvisoryRating::Inoffensive`
|
||||||
- Renamed `TaggedFile::remove_tag` to `TaggedFile::take`
|
- Renamed `TaggedFile::remove_tag` to `TaggedFile::take`
|
||||||
- **Vorbis Comments**: `VorbisComments::insert_picture` now accepts a user provided `PictureInformation`
|
- **Vorbis Comments**: `VorbisComments::insert_picture` now accepts a user provided `PictureInformation`
|
||||||
- **Vorbis Comments**: Rename `VorbisComments::{get_item, insert_item}` to `VorbisComments::{get, insert}`
|
- **Vorbis Comments**: Rename `VorbisComments::{get_item, insert_item, remove_key}` to `VorbisComments::{get, insert, remove}`
|
||||||
|
- **Vorbis Comments**: `VorbisComments::remove` now returns an iterator over the removed items
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- **MP4**: Non-full `meta` atoms are now properly handled.
|
- **MP4**: Non-full `meta` atoms are now properly handled.
|
||||||
|
|
|
@ -26,7 +26,7 @@ macro_rules! impl_accessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn [<remove_ $name>](&mut self) {
|
fn [<remove_ $name>](&mut self) {
|
||||||
self.remove_key($key)
|
let _ = self.remove($key);
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
|
@ -92,11 +92,21 @@ impl VorbisComments {
|
||||||
self.items.push((key, value))
|
self.items.push((key, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes an item by key
|
/// Removes all items with a key, returning an iterator
|
||||||
///
|
///
|
||||||
/// NOTE: This is case-sensitive
|
/// NOTE: This is case-sensitive
|
||||||
pub fn remove_key(&mut self, key: &str) {
|
pub fn remove(&mut self, key: &str) -> impl Iterator<Item = String> + '_ {
|
||||||
self.items.retain(|(k, _)| k != key);
|
// TODO: drain_filter
|
||||||
|
let mut split_idx = 0_usize;
|
||||||
|
|
||||||
|
for read_idx in 0..self.items.len() {
|
||||||
|
if self.items[read_idx].0 == key {
|
||||||
|
self.items.swap(split_idx, read_idx);
|
||||||
|
split_idx += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.items.drain(..split_idx).map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a [`Picture`]
|
/// Inserts a [`Picture`]
|
||||||
|
|
Loading…
Reference in a new issue