about summary refs log tree commit diff
path: root/library/std/src/sys/os_str
AgeCommit message (Collapse)AuthorLines
2025-08-20Move WTF-8 code from std to core/allocltdk-3/+5
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-6/+4
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-06-04Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=AmanieuMatthias Krüger-2/+2
make `OsString::new` and `PathBuf::new` unstably const Since #129041, `String::into_bytes` is `const`, which allows making `OsString::new` and `PathBuf::new` unstably const now. Not sure what the exact process for this is; does it need an ACP?
2025-05-24make `OsString::new` and `PathBuf::new` unstably constcyrgani-2/+2
2025-05-15Fix confusing WTF surrogate safety docsteor-3/+3
2025-04-30Make internal `OsString::truncate` and `extend_from_slice` unsafeThalia Archibald-18/+37
Communicate the safety invariants of these methods with `unsafe fn` rather than privacy.
2025-02-28Specialize OsString::push for stringsThalia Archibald-0/+10
When concatenating two WTF-8 strings, surrogate pairs at the boundaries need to be joined. However, since UTF-8 strings cannot contain surrogate halves, this check can be skipped when one string is UTF-8. Specialize `OsString::push` to use a more efficient concatenation in this case. Unfortunately, a specialization for `T: AsRef<str>` conflicts with `T: AsRef<OsStr>`, so stamp out string types with a macro.
2025-02-19Add fast path for displaying pre-validated Wtf8BufThalia Archibald-2/+2
2025-02-16Synchronize platform adaptors for OsString/OsStrThalia Archibald-74/+119
* Order items as the average of the two adaptors. Enables easier diffs. * Consistently apply #[inline]. * Implement FromInner<Vec<u8>> for bytes::Buf. * Implement Clone::clone_from for wtf8::Buf.
2024-11-12Make `CloneToUninit` dyn-compatibleZachary S-6/+6
2024-09-25Use `&raw` in the standard libraryJosh Stone-4/+2
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Sparkle some attributes over `CloneToUninit` stuffPavel Grigorenko-0/+2
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+24
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-17forbid(unsafe_op_in_unsafe_fn) in sys/os_strChris Denton-2/+2
2024-07-15Deny more windows unsafe_op_in_unsafe_fnChris Denton-2/+3
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-8/+23
#126333
2024-06-25inner truncate methods for UEFI platformsash-0/+5
2024-06-20Convert some module-level `//` and `///` comments to `//!`.Nicholas Nethercote-2/+3
This makes their intent and expected location clearer. We see some examples where these comments were not clearly separate from `use` declarations, which made it hard to understand what the comment is describing.
2024-06-04impl OsString::leak & PathBuf::leakschvv31n-0/+10
2024-04-26Rollup merge of #124410 - RalfJung:path-buf-transmute, r=NilstriebJacob Pratt-0/+12
PathBuf: replace transmuting by accessor functions The existing `repr(transparent)` was anyway insufficient as `OsString` was not `repr(transparent)`. And furthermore, on Windows it was blatantly wrong as `OsString` wraps `Wtf8Buf` which is a `repr(Rust)` type with 2 fields: https://github.com/rust-lang/rust/blob/51a7396ad3d78d9326ee1537b9ff29ab3919556f/library/std/src/sys_common/wtf8.rs#L131-L146 So let's just be honest about what happens and add accessor methods that make this abstraction-breaking act of PathBuf visible on the APIs that it pierces through. Fixes https://github.com/rust-lang/rust/issues/124409
2024-04-26PathBuf: replace transmuting by accessor functionsRalf Jung-0/+12
2024-04-24Stabilize Utf8ChunksDavid Tolnay-4/+2
2024-01-21Move `OsStr::slice_encoded_bytes` validation to platform modulesJan Verbeek-1/+49
On Windows and UEFI this improves performance and error messaging. On other platforms we optimize the fast path a bit more. This also prepares for later relaxing the checks on certain platforms.
2024-01-15std: move OS String implementation into `sys`joboet-0/+561