Skip to content

Commit

Permalink
Fix the documentation order of permissions_for_role and `permission…
Browse files Browse the repository at this point in the history
…s_for_user` (serenity-rs#862)
  • Loading branch information
7596ff authored May 15, 2020
1 parent 620faa2 commit 9356a5c
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,37 +572,6 @@ impl GuildChannel {
self.permissions_for_user(&cache, user_id.into())
}

/// Calculates the permissions of a role.
///
/// The Id of the argument must be a [`Role`] of the [`Guild`] that the
/// channel is in.
///
/// # Errors
///
/// Returns a [`ModelError::GuildNotFound`] if the channel's guild could
/// not be found in the [`Cache`].
///
/// Returns a [`ModelError::RoleNotFound`] if the given role could not
/// be found in the [`Cache`].
///
/// [`Cache`]: ../../cache/struct.Cache.html
/// [`ModelError::GuildNotFound`]: ../error/enum.Error.html#variant.GuildNotFound
/// [`ModelError::RoleNotFound`]: ../error/enum.Error.html#variant.RoleNotFound
/// [`Guild`]: ../guild/struct.Guild.html
/// [`Role`]: ../guild/struct.Role.html
#[cfg(feature = "cache")]
#[inline]
pub fn permissions_for_user<U: Into<UserId>>(&self, cache: impl AsRef<CacheRwLock>, user_id: U) -> Result<Permissions> {
self._permissions_for_user(&cache, user_id.into())
}

#[cfg(feature = "cache")]
fn _permissions_for_user(&self, cache: impl AsRef<CacheRwLock>, user_id: UserId) -> Result<Permissions> {
self.guild(&cache)
.ok_or_else(|| Error::Model(ModelError::GuildNotFound))
.map(|g| g.read().user_permissions_in(self.id, user_id))
}

/// Calculates the permissions of a member.
///
/// The Id of the argument must be a [`Member`] of the [`Guild`] that the
Expand Down Expand Up @@ -699,6 +668,37 @@ impl GuildChannel {
/// [Send Messages]: ../permissions/struct.Permissions.html#associatedconstant.SEND_MESSAGES
#[cfg(feature = "cache")]
#[inline]
pub fn permissions_for_user<U: Into<UserId>>(&self, cache: impl AsRef<CacheRwLock>, user_id: U) -> Result<Permissions> {
self._permissions_for_user(&cache, user_id.into())
}

#[cfg(feature = "cache")]
fn _permissions_for_user(&self, cache: impl AsRef<CacheRwLock>, user_id: UserId) -> Result<Permissions> {
self.guild(&cache)
.ok_or_else(|| Error::Model(ModelError::GuildNotFound))
.map(|g| g.read().user_permissions_in(self.id, user_id))
}

/// Calculates the permissions of a role.
///
/// The Id of the argument must be a [`Role`] of the [`Guild`] that the
/// channel is in.
///
/// # Errors
///
/// Returns a [`ModelError::GuildNotFound`] if the channel's guild could
/// not be found in the [`Cache`].
///
/// Returns a [`ModelError::RoleNotFound`] if the given role could not
/// be found in the [`Cache`].
///
/// [`Cache`]: ../../cache/struct.Cache.html
/// [`ModelError::GuildNotFound`]: ../error/enum.Error.html#variant.GuildNotFound
/// [`ModelError::RoleNotFound`]: ../error/enum.Error.html#variant.RoleNotFound
/// [`Guild`]: ../guild/struct.Guild.html
/// [`Role`]: ../guild/struct.Role.html
#[cfg(feature = "cache")]
#[inline]
pub fn permissions_for_role<R: Into<RoleId>>(&self, cache: impl AsRef<CacheRwLock>, role_id: R) -> Result<Permissions> {
self._permissions_for_role(&cache, role_id.into())
}
Expand Down

0 comments on commit 9356a5c

Please sign in to comment.