Skip to content

Commit

Permalink
Use Option::insert()
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Apr 23, 2024
1 parent dc4ad16 commit 9612e90
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions crates/bitwarden/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,11 @@ impl Client {
user_key: EncString,
private_key: EncString,
) -> Result<&EncryptionSettings> {
self.encryption_settings =
Some(EncryptionSettings::new(master_key, user_key, private_key)?);
Ok(self
.encryption_settings
.as_ref()
.expect("Value is initialized previously"))
Ok(self.encryption_settings.insert(EncryptionSettings::new(
master_key,
user_key,
private_key,
)?))
}

#[cfg(feature = "internal")]
Expand All @@ -267,14 +266,12 @@ impl Client {
user_key: SymmetricCryptoKey,
private_key: EncString,
) -> Result<&EncryptionSettings> {
self.encryption_settings = Some(EncryptionSettings::new_decrypted_key(
user_key,
private_key,
)?);
Ok(self
.encryption_settings
.as_ref()
.expect("Value is initialized previously"))
.insert(EncryptionSettings::new_decrypted_key(
user_key,
private_key,
)?))
}

#[cfg(feature = "mobile")]
Expand All @@ -292,10 +289,8 @@ impl Client {
&mut self,
key: SymmetricCryptoKey,
) -> &EncryptionSettings {
self.encryption_settings = Some(EncryptionSettings::new_single_key(key));
self.encryption_settings
.as_ref()
.expect("Value is initialized previously")
.insert(EncryptionSettings::new_single_key(key))
}

#[cfg(feature = "internal")]
Expand Down

0 comments on commit 9612e90

Please sign in to comment.