-
Notifications
You must be signed in to change notification settings - Fork 13.4k
It is not obvious how to construct a path from components #40159
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Is |
That’s the only way to construct a path with arbitrary number of components in a single statement without reallocating for every component that I could find. The other approach is to use |
Yeah let's put an example in the |
I will start working on this today. |
The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes rust-lang#40159
Add more ways to create a PathBuf to docs The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes rust-lang#40159 /cc @nagisa
Add more ways to create a PathBuf to docs The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes rust-lang#40159 /cc @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 aPathBuf
, but that sounds sort of inconvenient. There’s aimplementation 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?The text was updated successfully, but these errors were encountered: