diff options
| author | acdenisSK <[email protected]> | 2017-09-24 22:49:54 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-09-24 22:49:54 +0200 |
| commit | 47ea8f79b4e980e38fb337b2f3cefc5c7d92fb33 (patch) | |
| tree | da1bd72cbeba1fd5e7bffe61625cb589563373e7 /src | |
| parent | Revamp errors in `Args` and commands (diff) | |
| download | serenity-47ea8f79b4e980e38fb337b2f3cefc5c7d92fb33.tar.xz serenity-47ea8f79b4e980e38fb337b2f3cefc5c7d92fb33.zip | |
Refactor display impls for ids
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/channel/channel_id.rs | 5 | ||||
| -rw-r--r-- | src/model/guild/emoji.rs | 4 | ||||
| -rw-r--r-- | src/model/guild/guild_id.rs | 5 | ||||
| -rw-r--r-- | src/model/guild/role.rs | 5 | ||||
| -rw-r--r-- | src/model/mod.rs | 8 | ||||
| -rw-r--r-- | src/model/user.rs | 4 |
6 files changed, 7 insertions, 24 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index e5dad79..4cc997d 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -1,4 +1,3 @@ -use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; use internal::RwLockExt; @@ -556,7 +555,3 @@ impl<'a> From<&'a GuildChannel> for ChannelId { /// Gets the Id of a guild channel. fn from(public_channel: &GuildChannel) -> ChannelId { public_channel.id } } - -impl Display for ChannelId { - fn fmt(&self, f: &mut Formatter) -> FmtResult { Display::fmt(&self.0, f) } -} diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs index b7cc129..4a2190f 100644 --- a/src/model/guild/emoji.rs +++ b/src/model/guild/emoji.rs @@ -200,10 +200,6 @@ impl Display for Emoji { } } -impl Display for EmojiId { - fn fmt(&self, f: &mut Formatter) -> FmtResult { Display::fmt(&self.0, f) } -} - impl From<Emoji> for EmojiId { /// Gets the Id of an `Emoji`. fn from(emoji: Emoji) -> EmojiId { emoji.id } diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index dc060dd..39b7dbb 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -1,4 +1,3 @@ -use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(all(feature = "cache", feature = "model"))] @@ -484,10 +483,6 @@ impl GuildId { pub fn webhooks(&self) -> Result<Vec<Webhook>> { http::get_guild_webhooks(self.0) } } -impl Display for GuildId { - fn fmt(&self, f: &mut Formatter) -> FmtResult { Display::fmt(&self.0, f) } -} - impl From<PartialGuild> for GuildId { /// Gets the Id of a partial guild. fn from(guild: PartialGuild) -> GuildId { guild.id } diff --git a/src/model/guild/role.rs b/src/model/guild/role.rs index e097311..7ac7019 100644 --- a/src/model/guild/role.rs +++ b/src/model/guild/role.rs @@ -1,5 +1,4 @@ use std::cmp::Ordering; -use std::fmt::{Display, Formatter, Result as FmtResult}; use model::*; #[cfg(all(feature = "cache", feature = "model"))] @@ -187,10 +186,6 @@ impl RoleId { } } -impl Display for RoleId { - fn fmt(&self, f: &mut Formatter) -> FmtResult { Display::fmt(&self.0, f) } -} - impl From<Role> for RoleId { /// Gets the Id of a role. fn from(role: Role) -> RoleId { role.id } diff --git a/src/model/mod.rs b/src/model/mod.rs index b5ffc69..6b6d9bf 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -35,7 +35,7 @@ use chrono::NaiveDateTime; use self::utils::*; use serde::de::Visitor; use std::collections::HashMap; -use std::fmt::{Formatter, Result as FmtResult}; +use std::fmt::{Display, Formatter, Result as FmtResult}; use std::sync::{Arc, RwLock}; use internal::prelude::*; @@ -79,6 +79,12 @@ macro_rules! id_u64 { } } + impl Display for $name { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + Display::fmt(&self.0, f) + } + } + impl<'de> Deserialize<'de> for $name { fn deserialize<D: Deserializer<'de>>(deserializer: D) -> StdResult<Self, D::Error> { deserializer.deserialize_u64(U64Visitor).map($name) diff --git a/src/model/user.rs b/src/model/user.rs index a214b3d..bc22957 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -769,10 +769,6 @@ impl<'a> From<&'a User> for UserId { fn from(user: &User) -> UserId { user.id } } -impl fmt::Display for UserId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) } -} - #[cfg(feature = "model")] fn avatar_url(user_id: UserId, hash: Option<&String>) -> Option<String> { hash.map(|hash| { |