Skip to content

Commit

Permalink
Replace with std::mem::take
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jan 19, 2024
1 parent 8c869f2 commit 74a5b08
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions crates/bitwarden-crypto/src/decrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ impl<V: Zeroize> Decrypted<V> {
impl TryFrom<Decrypted<Vec<u8>>> for Decrypted<String> {
type Error = CryptoError;

fn try_from(v: Decrypted<Vec<u8>>) -> Result<Self, CryptoError> {
let mut str = v.expose().to_owned();

let rtn = String::from_utf8(str).map_err(|_| CryptoError::InvalidUtf8String);

str.zeroize();
fn try_from(mut v: Decrypted<Vec<u8>>) -> Result<Self, CryptoError> {
let value = std::mem::take(&mut v.value);

let rtn = String::from_utf8(value).map_err(|_| CryptoError::InvalidUtf8String);
rtn.map(Decrypted::new)
}
}

0 comments on commit 74a5b08

Please sign in to comment.