Skip to content

Commit be70d38

Browse files
committed
fix(crypto): Use the from constructor for some maps with known values
1 parent 1e70b4f commit be70d38

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

crates/matrix-sdk-crypto/src/olm/account.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -746,17 +746,16 @@ impl ReadOnlyAccount {
746746

747747
pub(crate) fn unsigned_device_keys(&self) -> DeviceKeys {
748748
let identity_keys = self.identity_keys();
749-
750-
let mut keys = BTreeMap::new();
751-
752-
keys.insert(
753-
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Curve25519, &self.device_id),
754-
identity_keys.curve25519().to_owned(),
755-
);
756-
keys.insert(
757-
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, &self.device_id),
758-
identity_keys.ed25519().to_owned(),
759-
);
749+
let keys = BTreeMap::from([
750+
(
751+
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Curve25519, &self.device_id),
752+
identity_keys.curve25519().to_owned(),
753+
),
754+
(
755+
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, &self.device_id),
756+
identity_keys.ed25519().to_owned(),
757+
),
758+
]);
760759

761760
DeviceKeys::new(
762761
(*self.user_id).clone(),

crates/matrix-sdk-crypto/src/olm/signing/pk_signing.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,11 @@ impl Signing {
397397
}
398398

399399
pub fn cross_signing_key(&self, user_id: UserId, usage: KeyUsage) -> CrossSigningKey {
400-
let mut keys = BTreeMap::new();
401-
402-
keys.insert(
400+
let keys = BTreeMap::from([(
403401
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, self.public_key().as_str().into())
404402
.to_string(),
405403
self.public_key().to_string(),
406-
);
404+
)]);
407405

408406
CrossSigningKey::new(user_id, vec![usage], keys, BTreeMap::new())
409407
}

0 commit comments

Comments
 (0)