Skip to content

Commit

Permalink
Replace Option.map_or(false) with is_some_and
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Feb 7, 2024
1 parent ac6d85b commit 820b2be
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/commands/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ fn check_valid_voice(data: &Data, code: &FixedString, mode: TTSMode) -> bool {
TTSMode::gCloud => code
.split_once(' ')
.and_then(|(language, variant)| data.gcloud_voices.get(language).map(|l| (l, variant)))
.map_or(false, |(ls, v)| ls.contains_key(v)),
.is_some_and(|(ls, v)| ls.contains_key(v)),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/events/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ async fn process_tts_msg(
};
}

let is_ephemeral = message.flags.map_or(false, |f| {
f.contains(serenity::model::channel::MessageFlags::EPHEMERAL)
});
let is_ephemeral = message
.flags
.is_some_and(|f| f.contains(serenity::model::channel::MessageFlags::EPHEMERAL));

let m;
let member_nick = match &message.member {
Expand Down
2 changes: 1 addition & 1 deletion src/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub async fn run_checks(
let channel = guild.channels.get(&voice_channel).try_unwrap()?;

if channel.kind == serenity::ChannelType::Stage
&& voice_state.map_or(false, serenity::VoiceState::suppress)
&& voice_state.is_some_and(serenity::VoiceState::suppress)
&& guild_row.audience_ignore()
{
return Ok(None); // Is audience
Expand Down
2 changes: 1 addition & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl Data {
if mode.is_premium() && !guild_is_premium {
mode = TTSMode::default();

if user_row.voice_mode.map_or(false, TTSMode::is_premium) {
if user_row.voice_mode.is_some_and(TTSMode::is_premium) {
warn!(
"User ID {author_id}'s normal voice mode is set to a premium mode! Resetting."
);
Expand Down
2 changes: 1 addition & 1 deletion src/translations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn read_files() -> Result<HashMap<FixedString<u8>, gettext::Catalog>> {
.unwrap()
.map(Result::unwrap)
.filter(filter_entry(EntryCheck::IsFile))
.filter(|e| e.path().extension().map_or(false, |e| e == "mo"))
.filter(|e| e.path().extension().is_some_and(|e| e == "mo"))
.map(|entry| {
let os_file_path = entry.file_name();
let file_path = os_file_path.to_str().unwrap();
Expand Down

0 comments on commit 820b2be

Please sign in to comment.