Remove unnecessary code, operations, and annotations that don’t add value. This includes redundant type annotations when types are already constrained, unnecessary conditional checks, redundant operations like path normalization in multiple places, and overly complex patterns that can be simplified.
Examples of improvements:
let out_property: BoxedTemplateProperty<'a, bool> =
→ let out_property =
when the type is already constrained by the function signatureif created_dirs.write().await.insert(dir_path.clone()) {
→ just use created_dirs.write().await.insert(dir_path.clone());
when the condition isn’t neededmatch expression.evaluate(repo) { Ok(_) => Ok(()), Err(e) => Err(e) }
→ expression.evaluate(repo).map(|_| ())
let mut hint = ui.hint_default(); writeln!(hint, "...")?;
, directly use writeln!(ui.hint_default(), "...")?;
Focus on the principle that code should be as simple and direct as possible while maintaining clarity and correctness.
Enter the URL of a public GitHub repository