Skip to content

Lint idea: file_name obtained from a call to path obtained from a DirEntry #1664

@smoelius

Description

@smoelius

Should use DirEntry::file_name instead.

DirEntry::file_name returns an OsString.

DirEntry::path returns a PathBuf (a larger allocation) and Path::file_name returns an Option<&OsStr> (a more complicated type).

As mentioned in #920, clippy_utils has expr_or_init, which can help with lightweight dataflow problems like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lintNew lint or lint enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions