Skip to content

Commit

Permalink
♻️ shorten
Browse files Browse the repository at this point in the history
  • Loading branch information
Roms1383 committed Aug 30, 2024
1 parent 941c027 commit fbd0543
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
5 changes: 1 addition & 4 deletions bank/src/ensure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,7 @@ pub fn ensure_store_data<T: PartialEq + Eq + Hash + Clone + Into<Key>>(
path: &impl AsRef<std::path::Path>,
store: &mut HashMap<T, StaticSoundData>,
) -> Result<(), Error> {
let value = match settings {
Some(settings) => value.with(settings),
None => value,
};
let value = value.with(settings);
ensure!(
store.insert(key.clone(), value).is_none(),
CannotStoreDataSnafu {
Expand Down
14 changes: 2 additions & 12 deletions manifest/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,7 @@ impl From<AnyAudio> for Audio {

impl From<(AnyAudio, Option<&Settings>)> for Audio {
fn from((audio, settings): (AnyAudio, Option<&Settings>)) -> Self {
let mut audio: Audio = audio.into();
if let Some(settings) = settings {
audio = audio.with(settings.clone());
}
audio
Audio::from(audio).with(Option::<&Settings>::cloned(settings))
}
}

Expand Down Expand Up @@ -232,13 +228,7 @@ pub fn any_audios_into_audios<K: PartialEq + Eq + Hash>(
) -> HashMap<K, Audio> {
value
.into_iter()
.map(|(k, v)| {
let mut v: Audio = v.into();
if let Some(ref settings) = settings {
v = v.with(settings.clone());
}
(k, v)
})
.map(|(k, v)| (k, Audio::from(v).with(settings.clone())))
.collect()
}

Expand Down
16 changes: 3 additions & 13 deletions manifest/src/de/voice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ impl From<&Dialog> for Audio {

impl From<(&Dialog, Option<&Settings>)> for Audio {
fn from(value: (&Dialog, Option<&Settings>)) -> Self {
let mut audio: Audio = value.into();
if let Some(settings) = value.1 {
audio = audio.with(settings.clone());
}
audio
Into::<Audio>::into(value).with(Option::<&Settings>::cloned(value.1))
}
}

Expand Down Expand Up @@ -158,14 +154,8 @@ impl From<Voice> for AnyVoice {
aud.insert(
k,
GenderBased {
fem: settings.clone().map_or(dialogs.fem.basic.clone(), |x| {
dialogs.fem.basic.with(x)
}),
male: settings
.clone()
.map_or(dialogs.male.basic.clone(), |x| {
dialogs.male.basic.with(x)
}),
fem: dialogs.fem.basic.with(settings.clone()),
male: dialogs.male.basic.with(settings.clone()),
},
);
sub.insert(
Expand Down

0 comments on commit fbd0543

Please sign in to comment.