Change UserMeta: User instead of Option<User>

I do not know why I have made it optional in the first place. hm
This commit is contained in:
bitfl0wer 2023-06-10 00:35:51 +02:00
parent dde43d9752
commit 972100af65
4 changed files with 5 additions and 8 deletions

View File

@ -63,7 +63,7 @@ pub mod login {
login_result.token,
cloned_limits,
login_result.settings,
Some(object),
object,
);
Ok(user)

View File

@ -71,7 +71,7 @@ pub mod register {
token.clone(),
cloned_limits,
settings,
Some(user_object),
user_object,
);
Ok(user)
}

View File

@ -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)
}

View File

@ -90,7 +90,7 @@ pub struct UserMeta {
pub token: String,
pub limits: Limits,
pub settings: UserSettings,
pub object: Option<User>,
pub object: User,
}
impl UserMeta {
@ -107,7 +107,7 @@ impl UserMeta {
token: String,
limits: Limits,
settings: UserSettings,
object: Option<User>,
object: User,
) -> UserMeta {
UserMeta {
belongs_to,