aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-05-04 12:54:58 -0700
committerZeyla Hellyer <[email protected]>2017-05-04 12:54:58 -0700
commit4cdaf3a3187125971bdc9e5c5e52b36d70f563c2 (patch)
treeba4ee4bf1d9d6f9c3a8122c5ee99657c26ddd99b /src/model/guild
parentAdd missing Member::kick shortcut (diff)
downloadserenity-4cdaf3a3187125971bdc9e5c5e52b36d70f563c2.tar.xz
serenity-4cdaf3a3187125971bdc9e5c5e52b36d70f563c2.zip
Accept references on Into<Id>
By accepting references, users don't have to either pass in the entirity of an instance or clone it.
Diffstat (limited to 'src/model/guild')
-rw-r--r--src/model/guild/emoji.rs7
-rw-r--r--src/model/guild/guild_id.rs28
-rw-r--r--src/model/guild/role.rs7
3 files changed, 42 insertions, 0 deletions
diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs
index 54a70d3..4c2b6fc 100644
--- a/src/model/guild/emoji.rs
+++ b/src/model/guild/emoji.rs
@@ -127,3 +127,10 @@ impl From<Emoji> for EmojiId {
emoji.id
}
}
+
+impl<'a> From<&'a 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 f219659..6e5cb3a 100644
--- a/src/model/guild/guild_id.rs
+++ b/src/model/guild/guild_id.rs
@@ -607,6 +607,13 @@ impl From<PartialGuild> for GuildId {
}
}
+impl<'a> From<&'a PartialGuild> for GuildId {
+ /// Gets the Id of a partial guild.
+ fn from(guild: &PartialGuild) -> GuildId {
+ guild.id
+ }
+}
+
impl From<GuildInfo> for GuildId {
/// Gets the Id of Guild information struct.
fn from(guild_info: GuildInfo) -> GuildId {
@@ -614,6 +621,13 @@ impl From<GuildInfo> for GuildId {
}
}
+impl<'a> From<&'a GuildInfo> for GuildId {
+ /// Gets the Id of Guild information struct.
+ fn from(guild_info: &GuildInfo) -> GuildId {
+ guild_info.id
+ }
+}
+
impl From<InviteGuild> for GuildId {
/// Gets the Id of Invite Guild struct.
fn from(invite_guild: InviteGuild) -> GuildId {
@@ -621,9 +635,23 @@ impl From<InviteGuild> for GuildId {
}
}
+impl<'a> From<&'a InviteGuild> for GuildId {
+ /// Gets the Id of Invite Guild struct.
+ fn from(invite_guild: &InviteGuild) -> GuildId {
+ invite_guild.id
+ }
+}
+
impl From<Guild> for GuildId {
/// Gets the Id of Guild.
fn from(live_guild: Guild) -> GuildId {
live_guild.id
}
}
+
+impl<'a> From<&'a Guild> for GuildId {
+ /// Gets the Id of Guild.
+ fn from(live_guild: &Guild) -> GuildId {
+ live_guild.id
+ }
+}
diff --git a/src/model/guild/role.rs b/src/model/guild/role.rs
index d4e1da8..58f91de 100644
--- a/src/model/guild/role.rs
+++ b/src/model/guild/role.rs
@@ -199,3 +199,10 @@ impl From<Role> for RoleId {
role.id
}
}
+
+impl<'a> From<&'a Role> for RoleId {
+ /// Gets the Id of a role.
+ fn from(role: &Role) -> RoleId {
+ role.id
+ }
+}