Skip to content

It is not obvious how to construct a path from components #40159

Closed
@nagisa

Description

@nagisa

The only really cross-platform method to construct a path, is to construct one from components. For example os.path.join is a well known way to do so in Python.

In Rust is not as obvious how to do that in a convenient manner. You could push components one-by-one into a PathBuf, but that sounds sort of inconvenient. There’s a

impl<P: AsRef<Path>> FromIterator<P> for PathBuf

implementation exactly for that, but it is extremely difficult to discover. Perhaps what we need is a in-your-face example on PathBuf that explains the only really correct way to construct a multi-component PathBuf?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsP-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions