Skip to content

Commit

Permalink
chore(plugins/memes): fix clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rupansh committed Nov 24, 2023
1 parent 350adfd commit 9e8b849
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/plugins/memes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use grammers_client::types::{InputMessage, Message};
use rand::seq::SliceRandom;
use rand::Rng;

use std::fmt::Write;

/// owo text (・`ω´・)
///
/// ## Scope
Expand Down Expand Up @@ -73,24 +75,22 @@ pub async fn stretch_handler(bot: &mut UserBot, message: &mut Message) -> Comman
pub async fn vapor_handler(bot: &mut UserBot, message: &mut Message) -> CommandHandlerResult {
let arg = &bot.get_args_text(message, false).await?[0];

let res: String = arg
.as_str()
.chars()
.map(|charac| {
format!(
"{}{}",
if charac.is_whitespace() { " " } else { "" },
if 0x21 <= charac as u32 && charac as u32 <= 0x7F {
std::char::from_u32(charac as u32 + 0xFEE0)
.unwrap_or(std::char::REPLACEMENT_CHARACTER)
} else if charac as u32 == 0x20 {
std::char::from_u32(0x3000).unwrap()
} else {
charac
}
)
})
.collect();
let res: String = arg.as_str().chars().fold(String::new(), |mut out, charac| {
let _ = write!(
out,
"{}{}",
if charac.is_whitespace() { " " } else { "" },
if 0x21 <= charac as u32 && charac as u32 <= 0x7F {
std::char::from_u32(charac as u32 + 0xFEE0)
.unwrap_or(std::char::REPLACEMENT_CHARACTER)
} else if charac as u32 == 0x20 {
std::char::from_u32(0x3000).unwrap()
} else {
charac
}
);
out
});

message.edit(InputMessage::text(res)).await?;
Ok(())
Expand Down

0 comments on commit 9e8b849

Please sign in to comment.