From a18eab18843bcd3de4692180241161816c20d13b Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 10 Jun 2023 00:35:51 +0200 Subject: [PATCH] Change UserMeta: User instead of Option I do not know why I have made it optional in the first place. hm --- src/api/auth/login.rs | 2 +- src/api/auth/register.rs | 2 +- src/api/users/users.rs | 5 +---- src/instance.rs | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/api/auth/login.rs b/src/api/auth/login.rs index 2481cd6..55d7799 100644 --- a/src/api/auth/login.rs +++ b/src/api/auth/login.rs @@ -63,7 +63,7 @@ pub mod login { login_result.token, cloned_limits, login_result.settings, - Some(object), + object, ); Ok(user) diff --git a/src/api/auth/register.rs b/src/api/auth/register.rs index 8ca4735..d961fbf 100644 --- a/src/api/auth/register.rs +++ b/src/api/auth/register.rs @@ -71,7 +71,7 @@ pub mod register { token.clone(), cloned_limits, settings, - Some(user_object), + user_object, ); Ok(user) } diff --git a/src/api/users/users.rs b/src/api/users/users.rs index ffabd3f..1d35f32 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -72,10 +72,7 @@ impl UserMeta { Err(e) => return Err(e), }; let user_updated: User = from_str(&result.text().await.unwrap()).unwrap(); - let _ = std::mem::replace( - &mut self.object.as_mut().unwrap(), - &mut user_updated.clone(), - ); + let _ = std::mem::replace(&mut self.object, user_updated.clone()); Ok(user_updated) } diff --git a/src/instance.rs b/src/instance.rs index 6121c65..524735b 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -90,7 +90,7 @@ pub struct UserMeta { pub token: String, pub limits: Limits, pub settings: UserSettings, - pub object: Option, + pub object: User, } impl UserMeta { @@ -107,7 +107,7 @@ impl UserMeta { token: String, limits: Limits, settings: UserSettings, - object: Option, + object: User, ) -> UserMeta { UserMeta { belongs_to,