diff options
| author | Zeyla Hellyer <[email protected]> | 2017-05-04 12:54:58 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-04 12:54:58 -0700 |
| commit | 4cdaf3a3187125971bdc9e5c5e52b36d70f563c2 (patch) | |
| tree | ba4ee4bf1d9d6f9c3a8122c5ee99657c26ddd99b /src/model/guild/guild_id.rs | |
| parent | Add missing Member::kick shortcut (diff) | |
| download | serenity-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.rs | 28 |
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 + } +} |