diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-26 12:12:42 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-26 12:12:42 -0500 |
| commit | 9c0f3f7f2ae2492542fea99338fac13242cfe25e (patch) | |
| tree | c0e1b202955985824ae38cb804167f7aab6d5fe4 /src/libstd | |
| parent | 3ac40b69c75929dac5115b6a49eb4f1ecc352416 (diff) | |
| download | rust-9c0f3f7f2ae2492542fea99338fac13242cfe25e.tar.gz rust-9c0f3f7f2ae2492542fea99338fac13242cfe25e.zip | |
Document safety of Path casting
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 580ff1610ac..5278959b784 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -296,6 +296,13 @@ where } // See note at the top of this module to understand why these are used: +// +// These casts are safe as OsStr is internally a wrapper around [u8] on all +// platforms. +// +// Note that currently this relies on the special knowledge that libstd has; +// these types are single-element structs but are not marked repr(transparent) +// or repr(C) which would make these casts allowable outside std. fn os_str_as_u8_slice(s: &OsStr) -> &[u8] { unsafe { &*(s as *const OsStr as *const [u8]) } } |
