fix(types): use Box<str> instead String

This commit is contained in:
doryan 2025-04-03 12:15:41 +04:00
parent 35c1df8363
commit 51ec37b766
4 changed files with 5 additions and 5 deletions

View File

@ -41,7 +41,7 @@ pub async fn ban_member(
{ {
Ok(EventReturn::Cancel) Ok(EventReturn::Cancel)
} else { } else {
let banned_user_name: String = user.get_user_name(&bot, &message).await.unwrap(); let banned_user_name: Box<str> = user.get_user_name(&bot, &message).await.unwrap();
sender_builder sender_builder
.reply_to(message.id()) .reply_to(message.id())

View File

@ -45,7 +45,7 @@ pub async fn mute_member(
{ {
Ok(EventReturn::Cancel) Ok(EventReturn::Cancel)
} else { } else {
let muted_user_name: String = user.get_user_name(&bot, &message).await.unwrap(); let muted_user_name: Box<str> = user.get_user_name(&bot, &message).await.unwrap();
sender_builder sender_builder
.reply_to(message.id()) .reply_to(message.id())

View File

@ -46,7 +46,7 @@ pub async fn unmute_member(
Ok(EventReturn::Cancel) Ok(EventReturn::Cancel)
} else { } else {
let muted_user_name: String = user.get_user_name(&bot, &message).await.unwrap(); let muted_user_name: Box<str> = user.get_user_name(&bot, &message).await.unwrap();
sender_builder sender_builder
.reply_to(message.id()) .reply_to(message.id())

View File

@ -21,7 +21,7 @@ impl TargetUser {
Self::Id(_id) => true, Self::Id(_id) => true,
Self::Reply(msg) => { Self::Reply(msg) => {
if let Some(replied_msg) = msg.reply_to_message() { if let Some(replied_msg) = msg.reply_to_message() {
return replied_msg.from().map(|user| user.id).is_some(); replied_msg.from().map(|user| user.id).is_some()
} else { } else {
false false
} }
@ -46,7 +46,7 @@ impl TargetUser {
} }
} }
pub async fn get_user_name(&self, bot: &Bot, msg: &Message) -> Option<String> { pub async fn get_user_name(&self, bot: &Bot, msg: &Message) -> Option<Box<str>> {
match self { match self {
Self::Id(id) => { Self::Id(id) => {
let get_chat_member_result: Result<ChatMember, SessionErrorKind> = let get_chat_member_result: Result<ChatMember, SessionErrorKind> =