Skip to content

FN redundant_clone #5303

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr
use std::path::PathBuf;

fn main() {
	let x = PathBuf::from("home");
	let y = x.clone().join("matthias"); 
        // join() creates a new owned pathbuf, does not take a &mut to x variable, thus the .clone() is redundant.(It also does not consume the PB)

	println!("x: {:?}, y: {:?}", x, y);
     // "x: "home", y: "home/matthias""
}

In this example let y = x.clone().join("matthias"); could just be let y = x.join("matthias");

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-hardCall for participation: This a hard problem and requires more experience or effort to work onL-perfLint: Belongs in the perf lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions