Skip to content

Commit

Permalink
Make utils::shard_id accept the guild id with impl Into<u64> (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyWX authored Oct 27, 2020
1 parent b210a60 commit 85b5489
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ pub fn parse_quotes(s: impl AsRef<str>) -> Vec<String> {
/// ```rust
/// use serenity::utils;
///
/// assert_eq!(utils::shard_id(81384788765712384, 17), 7);
/// assert_eq!(utils::shard_id(81384788765712384 as u64, 17), 7);
/// ```
#[inline]
pub fn shard_id(guild_id: u64, shard_count: u64) -> u64 { (guild_id >> 22) % shard_count }
pub fn shard_id(guild_id: impl Into<u64>, shard_count: u64) -> u64 { (guild_id.into() >> 22) % shard_count }

/// Struct that allows to alter [`content_safe`]'s behaviour.
///
Expand Down

0 comments on commit 85b5489

Please sign in to comment.