chore: Fix clippy lints

Automated with cargo clippy --fix.
This commit is contained in:
Jonas Platte
2022-10-25 10:58:51 +02:00
committed by Jonas Platte
parent 9de98dfa65
commit a59fdc08bb
12 changed files with 23 additions and 24 deletions

View File

@@ -60,7 +60,7 @@ pub struct MediaThumbnailSize {
impl UniqueKey for MediaThumbnailSize {
fn unique_key(&self) -> String {
format!("{}{}{}x{}", self.method, UNIQUE_SEPARATOR, self.width, self.height)
format!("{}{UNIQUE_SEPARATOR}{}x{}", self.method, self.width, self.height)
}
}
@@ -85,7 +85,7 @@ pub struct MediaRequest {
impl UniqueKey for MediaRequest {
fn unique_key(&self) -> String {
format!("{}{}{}", self.source.unique_key(), UNIQUE_SEPARATOR, self.format.unique_key())
format!("{}{UNIQUE_SEPARATOR}{}", self.source.unique_key(), self.format.unique_key())
}
}
/// Trait for media event content.

View File

@@ -96,7 +96,7 @@ impl SecretInfo {
info.session_id(),
&info.algorithm(),
),
SecretInfo::SecretRequest(ref sname) => format!("secretName:{:}", sname),
SecretInfo::SecretRequest(ref sname) => format!("secretName:{sname:}"),
}
}
}

View File

@@ -1981,7 +1981,7 @@ pub(crate) mod tests {
if let AnyToDeviceEvent::Dummy(e) = event {
assert_eq!(&e.sender, alice.user_id());
} else {
panic!("Wrong event type found {:?}", event);
panic!("Wrong event type found {event:?}");
}
}
@@ -2019,7 +2019,7 @@ pub(crate) mod tests {
assert_eq!(&event.sender, alice.user_id());
assert!(event.content.session_key.is_empty());
} else {
panic!("expected RoomKeyEvent found {:?}", event);
panic!("expected RoomKeyEvent found {event:?}");
}
let session =
@@ -2298,7 +2298,7 @@ pub(crate) mod tests {
// Bob verifies that the MAC is valid and also sends a "done" message.
let msgs = bob.verification_machine.outgoing_messages();
eprintln!("{:?}", msgs);
eprintln!("{msgs:?}");
assert!(msgs.len() == 1);
let event = msgs.first().map(|r| outgoing_request_to_event(bob.user_id(), r)).unwrap();
@@ -2319,7 +2319,7 @@ pub(crate) mod tests {
assert!(!alice_sas.is_done());
assert!(!bob_device.is_verified());
// Alices receives the done message
eprintln!("{:?}", event);
eprintln!("{event:?}");
alice.handle_verification_event(&event).await;
assert!(alice_sas.is_done());

View File

@@ -138,7 +138,7 @@ impl OlmMessageHash {
let sha = Sha256::new()
.chain_update(sender_key.as_bytes())
.chain_update([message_type as u8])
.chain_update(&ciphertext)
.chain_update(ciphertext)
.finalize();
Self { sender_key, hash: encode(sha.as_slice()) }

View File

@@ -100,7 +100,7 @@ pub fn format_emojis(emojis: [Emoji; 7]) -> String {
// Hack to make terminals behave properly when one of the above is printed.
let emoji = if VARIATION_SELECTOR_EMOJIS.contains(&emoji) {
format!("{} ", emoji)
format!("{emoji} ")
} else {
emoji.to_owned()
};
@@ -109,13 +109,12 @@ pub fn format_emojis(emojis: [Emoji; 7]) -> String {
// monospace characters.
let placeholder = ".".repeat(EMOJI_WIDTH);
format!("{:^12}", placeholder).replace(&placeholder, &emoji)
format!("{placeholder:^12}").replace(&placeholder, &emoji)
};
let emoji_string = emojis.iter().map(|e| center_emoji(e)).collect::<Vec<_>>().join("");
let description =
descriptions.iter().map(|d| format!("{:^12}", d)).collect::<Vec<_>>().join("");
let description = descriptions.iter().map(|d| format!("{d:^12}")).collect::<Vec<_>>().join("");
format!("{emoji_string}\n{description}")
}

View File

@@ -62,7 +62,7 @@ pub fn calculate_commitment(public_key: Curve25519PublicKey, content: &StartCont
Base64::new(
Sha256::new()
.chain_update(public_key.to_base64())
.chain_update(&content_string)
.chain_update(content_string)
.finalize()
.as_slice()
.to_owned(),
@@ -228,7 +228,7 @@ pub fn receive_mac_event(
if let Some(key) = ids.other_device.keys().get(&key_id) {
let calculated_mac = Base64::parse(
sas.calculate_mac_invalid_base64(&key.to_base64(), &format!("{}{}", info, key_id)),
sas.calculate_mac_invalid_base64(&key.to_base64(), &format!("{info}{key_id}")),
)
.expect("Can't base64-decode SAS MAC");

View File

@@ -140,7 +140,7 @@ impl IndexeddbCryptoStore {
prefix: &str,
store_cipher: Option<Arc<StoreCipher>>,
) -> Result<Self> {
let name = format!("{:0}::matrix-sdk-crypto", prefix);
let name = format!("{prefix:0}::matrix-sdk-crypto");
// Open my_db v1
let mut db_req: OpenDbRequest = IdbDatabase::open_f64(&name, 1.1)?;
@@ -232,7 +232,7 @@ impl IndexeddbCryptoStore {
/// Open a new `IndexeddbCryptoStore` with given name and passphrase
pub async fn open_with_passphrase(prefix: &str, passphrase: &str) -> Result<Self> {
let name = format!("{:0}::matrix-sdk-crypto-meta", prefix);
let name = format!("{prefix:0}::matrix-sdk-crypto-meta");
let mut db_req: OpenDbRequest = IdbDatabase::open_f64(&name, 1.0)?;
db_req.set_on_upgrade_needed(Some(|evt: &IdbVersionChangeEvent| -> Result<(), JsValue> {
@@ -907,7 +907,7 @@ impl IndexeddbCryptoStore {
if let Some(inner) = request {
tx.object_store(KEYS::SECRET_REQUESTS_BY_INFO)?
.delete(&self.encode_key(KEYS::KEY_REQUEST, &inner.info.as_key()))?;
.delete(&self.encode_key(KEYS::KEY_REQUEST, inner.info.as_key()))?;
}
tx.object_store(KEYS::UNSENT_SECRET_REQUESTS)?.delete(&jskey)?;

View File

@@ -61,7 +61,7 @@ pub trait SafeEncode {
/// encode self into a JsValue, internally using `as_encoded_string`
/// to escape the value of self, and append the given counter
fn encode_with_counter(&self, i: usize) -> JsValue {
format!("{}{}{:016x}", self.as_encoded_string(), KEY_SEPARATOR, i).into()
format!("{}{KEY_SEPARATOR}{i:016x}", self.as_encoded_string()).into()
}
/// encode self into a JsValue, internally using `as_secure_string`

View File

@@ -191,7 +191,7 @@ fn create_stores(db: &IdbDatabase) -> Result<(), JsValue> {
async fn backup(source: &IdbDatabase, meta: &IdbDatabase) -> Result<()> {
let now = JsDate::now();
let backup_name = format!("backup-{}-{}", source.name(), now);
let backup_name = format!("backup-{}-{now}", source.name());
let mut db_req: OpenDbRequest = IdbDatabase::open_f64(&backup_name, source.version())?;
db_req.set_on_upgrade_needed(Some(move |evt: &IdbVersionChangeEvent| -> Result<(), JsValue> {
@@ -257,7 +257,7 @@ impl IndexeddbStateStoreBuilder {
.unwrap_or(MigrationConflictStrategy::BackupAndDrop);
let name = self.name.clone().unwrap_or_else(|| "state".to_owned());
let meta_name = format!("{}::{}", name, KEYS::INTERNAL_STATE);
let meta_name = format!("{name}::{}", KEYS::INTERNAL_STATE);
let mut db_req: OpenDbRequest =
IdbDatabase::open_f64(&meta_name, KEYS::CURRENT_META_DB_VERSION)?;

View File

@@ -792,7 +792,7 @@ impl CryptoStore for SledCryptoStore {
let key = self.encode_key(INBOUND_GROUP_TABLE_NAME, (room_id, session_id));
let pickle = self
.inbound_group_sessions
.get(&key)
.get(key)
.map_err(CryptoStoreError::backend)?
.map(|p| self.deserialize_value(&p));

View File

@@ -690,7 +690,7 @@ impl SledStateStore {
let make_room_version = |room_id| {
self.room_info
.get(&self.encode_key(ROOM_INFO, room_id))
.get(self.encode_key(ROOM_INFO, room_id))
.ok()
.flatten()
.map(|r| self.deserialize_value::<RoomInfo>(&r))
@@ -1577,7 +1577,7 @@ mod migration {
if let Err(SledStoreError::MigrationConflict { .. }) = res {
// all good
} else {
panic!("Didn't raise the expected error: {:?}", res);
panic!("Didn't raise the expected error: {res:?}");
}
assert_eq!(std::fs::read_dir(folder.path())?.count(), 1);
Ok(())

View File

@@ -319,7 +319,7 @@ impl From<SdkBaseError> for Error {
_ => Self::UnknownError(anyhow::anyhow!(e).into()),
#[cfg(all(not(feature = "eyre"), not(feature = "anyhow")))]
_ => {
let e: Box<dyn std::error::Error + Sync + Send> = format!("{:?}", e).into();
let e: Box<dyn std::error::Error + Sync + Send> = format!("{e:?}").into();
Self::UnknownError(e)
}
}