-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
If an assignment dominate all usages where it can reach, assignment can be replaced by a let
bind, instead of overwrite
Advantage
- less
mut
- like functional programming
- explicit dominance
- helpful in jumpping to definition in ide
Drawbacks
None (not sure)
Example
let mut x = "hello".to_string();
let mut y = vec![];
y.push(x);
x = "goodbye".to_string();
println!("{}", x);
Could be written as:
let mut x = "hello".to_string();
let mut y = vec![];
y.push(x);
let x = "goodbye".to_string();
println!("{}", x);
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints