jeudi 6 juillet 2017

Is there any performance difference between `if let` and `if` for a boolean?

For example:

let mut v = vec![2, 3, 4];
if let false = v.is_empty() {
    v.push(5);
}

vs:

let mut v = vec![2, 3, 4];
if !v.is_empty() {
    v.push(5);
}

My gut feeling is that it's trivial and doesn't matter.

Aucun commentaire:

Enregistrer un commentaire