Make it possible to use Path and friends on wasip2 without the so named feature #1525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(draft because this is a bit of a hack and needs some discussion first)
At the moment, it's not possible to use
&Path
,&OsStr
, etc. with rustix on WASIp2 without the nightly compiler (requires thewasip2
feature) asOsStrExt
andOsStringExt
require thewasip2
feature on WASIp2 so we can't useas_bytes()
onOsStr
and friends.However, the recommendation on the upstream issue is to just use
to_str
as WASI paths are Unicode. This PR does exactly that.@alexcrichton am I interpreting your comment correctly?
Alternatives:
OsStr::as_encoded_bytes
on wasi instead ofOsStrExt::as_bytes
. It will technically work but it also technically relies on an unstable representation (one that will likely never change on WASI, but still...).This PR has two parts:
OsString
andOsStr
, converting to utf8 strings where necessary.