Skip to content

Commit

Permalink
Delete redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Jan 13, 2024
1 parent e65fec4 commit cb719a6
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ impl Accessor for Tag {
);

fn track(&self) -> Option<u32> {
if let Some(i) = self.get_string(&ItemKey::TrackNumber) {
return i.parse::<u32>().ok();
}

None
self.get_u32_from_string(&ItemKey::TrackNumber)
}

fn set_track(&mut self, value: u32) {
Expand All @@ -141,11 +137,7 @@ impl Accessor for Tag {
}

fn track_total(&self) -> Option<u32> {
if let Some(i) = self.get_string(&ItemKey::TrackTotal) {
return i.parse::<u32>().ok();
}

None
self.get_u32_from_string(&ItemKey::TrackTotal)
}

fn set_track_total(&mut self, value: u32) {
Expand All @@ -157,11 +149,7 @@ impl Accessor for Tag {
}

fn disk(&self) -> Option<u32> {
if let Some(i) = self.get_string(&ItemKey::DiscNumber) {
return i.parse::<u32>().ok();
}

None
self.get_u32_from_string(&ItemKey::DiscNumber)
}

fn set_disk(&mut self, value: u32) {
Expand All @@ -173,11 +161,7 @@ impl Accessor for Tag {
}

fn disk_total(&self) -> Option<u32> {
if let Some(i) = self.get_string(&ItemKey::DiscTotal) {
return i.parse::<u32>().ok();
}

None
self.get_u32_from_string(&ItemKey::DiscTotal)
}

fn set_disk_total(&mut self, value: u32) {
Expand Down Expand Up @@ -274,6 +258,11 @@ impl Tag {
None
}

fn get_u32_from_string(&self, key: &ItemKey) -> Option<u32> {
let i = self.get_string(key)?;
i.parse::<u32>().ok()
}

/// Gets a byte slice from an [`ItemKey`]
///
/// Use `convert` to convert [`ItemValue::Text`] and [`ItemValue::Locator`] to byte slices
Expand Down

0 comments on commit cb719a6

Please sign in to comment.