aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/guild_id.rs
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/guild_id.rs
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/guild_id.rs')
-rw-r--r--src/model/guild/guild_id.rs28
1 files changed, 28 insertions, 0 deletions
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
+ }
+}