Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove impl Into<Option> #2701

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/builder/edit_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ impl<'a> EditChannel<'a> {
/// [text]: ChannelType::Text
/// [voice]: ChannelType::Voice
#[inline]
pub fn category<C: Into<Option<ChannelId>>>(mut self, category: C) -> Self {
self.parent_id = Some(category.into());
pub fn category(mut self, category: Option<ChannelId>) -> Self {
self.parent_id = Some(category);
self
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4015,7 +4015,7 @@ impl Http {
message_id: MessageId,
reaction_type: &ReactionType,
limit: u8,
after: Option<u64>,
after: Option<UserId>,
) -> Result<Vec<User>> {
let mut params = ArrayVec::<_, 2>::new();
params.push(("limit", limit.to_string()));
Expand Down
10 changes: 2 additions & 8 deletions src/model/channel/channel_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,12 @@ impl ChannelId {
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<User>> {
let limit = limit.map_or(50, |x| if x > 100 { 100 } else { x });

http.as_ref()
.get_reaction_users(
self,
message_id.into(),
&reaction_type.into(),
limit,
after.into().map(UserId::get),
)
.get_reaction_users(self, message_id.into(), &reaction_type.into(), limit, after)
.await
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ impl GuildChannel {
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<User>> {
self.id.reaction_users(http, message_id, reaction_type, limit, after).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl Message {
http: impl AsRef<Http>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<User>> {
self.channel_id.reaction_users(http, self.id, reaction_type, limit, after).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/private_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl PrivateChannel {
message_id: impl Into<MessageId>,
reaction_type: impl Into<ReactionType>,
limit: Option<u8>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<User>> {
self.id.reaction_users(http, message_id, reaction_type, limit, after).await
}
Expand Down
15 changes: 5 additions & 10 deletions src/model/channel/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fmt::Display as _;
use std::fmt::{self, Write as _};
use std::str::FromStr;

use nonmax::NonMaxU8;
#[cfg(feature = "http")]
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use serde::de::{Deserialize, Error as DeError};
Expand Down Expand Up @@ -217,7 +218,7 @@ impl Reaction {
&self,
http: impl AsRef<Http>,
reaction_type: R,
limit: Option<u8>,
limit: Option<NonMaxU8>,
after: Option<U>,
) -> Result<Vec<User>>
where
Expand All @@ -231,24 +232,18 @@ impl Reaction {
&self,
http: impl AsRef<Http>,
reaction_type: &ReactionType,
limit: Option<u8>,
limit: Option<NonMaxU8>,
after: Option<UserId>,
) -> Result<Vec<User>> {
let mut limit = limit.unwrap_or(50);
let mut limit = limit.map_or(50, |limit| limit.get());

if limit > 100 {
limit = 100;
warn!("Reaction users limit clamped to 100! (API Restriction)");
}

http.as_ref()
.get_reaction_users(
self.channel_id,
self.message_id,
reaction_type,
limit,
after.map(UserId::get),
)
.get_reaction_users(self.channel_id, self.message_id, reaction_type, limit, after)
.await
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,9 @@ impl GuildId {
self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<Member>> {
http.as_ref().get_guild_members(self, limit, after.into().map(UserId::get)).await
http.as_ref().get_guild_members(self, limit, after.map(UserId::get)).await
}

/// Streams over all the members in a guild.
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ impl Guild {
&self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<Member>> {
self.id.members(http, limit, after).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ impl PartialGuild {
&self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: impl Into<Option<UserId>>,
after: Option<UserId>,
) -> Result<Vec<Member>> {
self.id.members(http, limit, after).await
}
Expand Down
Loading