Lyricdev
GitHub

LYR-SEM0217

'clone()' of a value a copy makes whole

warning · spec 08-expressions · lint redundant-clone, group style, warn unless said

clone() is called on a number, a bool, a char, a string, or a struct or an enum made of only such.

Explanation

An assignment copies such a value whole, and a string never changes: the copy is a value of its own, and clone() makes nothing a copy does not.

Use the value itself.

Wrong

fn main(): void {
    let name = "lyric";
    let copy = name.clone();
    let _ = copy;
}
fn main(): void {
    let name = "lyric";
    let copy = name;
    let _ = copy;
}