Favor concise and idiomatic expressions in your Rust code to improve readability and maintainability.
Favor concise and idiomatic expressions in your Rust code to improve readability and maintainability. Specifically:
// Prefer this
ident_ref.query.owned().await?
// Instead of this
(*ident_ref.query.await?).clone()
.to_string()
calls in format!
arguments when the type already implements Display
// Prefer this
format!("Check {} and {}", this.page, this.other_page)
// Instead of this
format!("Check {} and {}", this.page.to_string(), this.other_page.to_string())
serde::Serialize
and serde::Deserialize
when they’re not used
// Prefer this
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
// Instead of this when serialization isn't needed
#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
These practices reduce visual noise and make the intent of your code clearer.
Enter the URL of a public GitHub repository