-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document that /
works as separator on Windows
#42955
Conversation
Windows generally supports both, and I generally expect that Windows users know this, but there's no harm in pointing it out regardless! Thanks 😄 @bors: r+ rollup |
📌 Commit 40dec09 has been approved by |
Yeah, the problem is that I am not a windows user, but I do need to write cross platform software, so for me non-unix doc are more valuable exactly because I already know unix stuff :) |
Absolutely! I meant it more of a "this is why there's a blind spot" than "we shouldn't put it in here". |
Document that `/` works as separator on Windows Hi Whenever I see code like `Path::new("./src/bin/main.rs")` or `path.ends_with("foo/bar")`, I wonder if it will work on Windows as I expect. Unfortunately, reading the current docs does not help to answer this question, because all examples are Unix-specific. However, I believe that using `/` is fine, because both Windows itself [and Rust stdlib](https://github.com/rust-lang/rust/blob/47faf1d51952ecd9d4c8a7325332fba34fbe00bd/src/libstd/sys/windows/path.rs#L26) do treat it as a file separator, and because it is [actually used](https://github.com/rust-lang/cargo/blob/abf01e1eddb3145c83f71b469ea7bee37141e5e1/tests/git.rs#L579) in Cargo. So looks like we can just document it? r? @steveklabnik cc @retep998 I don't actually program for windows that much, so I might be totally wrong, and perhaps we should advise to always use (allocating) `.join` method to construct paths of more than one component?
While win32 paths in general support |
Document that `/` works as separator on Windows Hi Whenever I see code like `Path::new("./src/bin/main.rs")` or `path.ends_with("foo/bar")`, I wonder if it will work on Windows as I expect. Unfortunately, reading the current docs does not help to answer this question, because all examples are Unix-specific. However, I believe that using `/` is fine, because both Windows itself [and Rust stdlib](https://github.com/rust-lang/rust/blob/47faf1d51952ecd9d4c8a7325332fba34fbe00bd/src/libstd/sys/windows/path.rs#L26) do treat it as a file separator, and because it is [actually used](https://github.com/rust-lang/cargo/blob/abf01e1eddb3145c83f71b469ea7bee37141e5e1/tests/git.rs#L579) in Cargo. So looks like we can just document it? r? @steveklabnik cc @retep998 I don't actually program for windows that much, so I might be totally wrong, and perhaps we should advise to always use (allocating) `.join` method to construct paths of more than one component?
Found at least one case where allocating |
Hi Whenever I see code like
Path::new("./src/bin/main.rs")
orpath.ends_with("foo/bar")
, I wonder if it will work on Windows as I expect. Unfortunately, reading the current docs does not help to answer this question, because all examples are Unix-specific.However, I believe that using
/
is fine, because both Windows itself and Rust stdlib do treat it as a file separator, and because it is actually used in Cargo. So looks like we can just document it?r? @steveklabnik
cc @retep998 I don't actually program for windows that much, so I might be totally wrong, and perhaps we should advise to always use (allocating)
.join
method to construct paths of more than one component?