From af7f176101aea9bcf43551fbcd3261469bbc0b43 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Wed, 23 May 2018 21:14:43 -0700 Subject: impl From<{,&'a }CurrentUser> for User Implementation `From for User` and `From<&'a CurrentUser> for User`. --- src/model/user.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/model/user.rs b/src/model/user.rs index 227fadf..330f319 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -752,6 +752,30 @@ impl UserId { } } +impl From for User { + fn from(user: CurrentUser) -> Self { + Self { + avatar: user.avatar, + bot: user.bot, + discriminator: user.discriminator, + id: user.id, + name: user.name, + } + } +} + +impl<'a> From<&'a CurrentUser> for User { + fn from(user: &'a CurrentUser) -> Self { + Self { + avatar: user.avatar.clone(), + bot: user.bot, + discriminator: user.discriminator, + id: user.id, + name: user.name.clone(), + } + } +} + impl From for UserId { /// Gets the Id of a `CurrentUser` struct. fn from(current_user: CurrentUser) -> UserId { current_user.id } -- cgit v1.2.3