about summary refs log tree commit diff
path: root/library/std/src/ffi/os_str.rs
AgeCommit message (Collapse)AuthorLines
2025-09-26Update CURRENT_RUSTC_VERSION post-bumpMark Rousskov-1/+1
2025-09-01Constify conversion traitsltdk-4/+8
2025-08-15stabilize const pathbuf osstring newKivooeo-1/+1
2025-07-01Update version placeholdersJosh Stone-1/+1
2025-06-06Stabilised `os_string_pathbuf_leak`schvv31n-1/+1
2025-06-04Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=AmanieuMatthias Krüger-1/+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-26Rollup merge of #140936 - teor2345:wtf-surrogate-docs, r=workingjubileeJacob Pratt-3/+3
Clarify WTF-8 safety docs This PR is a follow-up to PR #140159, which clarifies ~~two things~~: - the WTF-8 safety comment [was confusing](https://github.com/rust-lang/rust/pull/140159#discussion_r2082766965), either surrogate condition is actually sufficient for safety, both are not required - ~~the private `os_str::Slice` type name is easily confused with `std::slice`~~ ~~Happy to bikeshed the `OsSlice` name, other alternatives are `OsStrSlice` and `StrSlice`. Now it's got a distinct name from `std::slice`, it's easy to search and replace.~~ cc ``@thaliaarchi`` ``@workingjubilee``
2025-05-24make `OsString::new` and `PathBuf::new` unstably constcyrgani-1/+2
2025-05-20use Self alias in self types rather than manually substituting itMichael Goulet-1/+1
2025-05-15Fix confusing WTF surrogate safety docsteor-3/+3
2025-04-30Make internal `OsString::truncate` and `extend_from_slice` unsafeThalia Archibald-6/+16
Communicate the safety invariants of these methods with `unsafe fn` rather than privacy.
2025-04-09replace version placeholderBoxy-4/+4
2025-02-28Specialize constructing OsString from stringsThalia Archibald-1/+24
The WTF-8 version of `OsString` tracks whether it is known to be valid UTF-8 with its `is_known_utf8` field. Specialize `From<AsRef<OsStr>>` so this can be set for UTF-8 string types.
2025-02-28Specialize OsString::push for stringsThalia Archibald-1/+24
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-20Stabilise `os_str_display`riverbl-6/+4
2025-01-21fix OsString::from_encoded_bytes_unchecked descriptionMarijn Schouten-2/+2
2025-01-06chore: remove redundant words in commentcrystalstall-1/+1
Signed-off-by: crystalstall <crystalruby@qq.com>
2024-11-27replace placeholder versionBoxy-3/+3
2024-11-20implement OsString::truncatebinarycat-4/+8
2024-11-12Make `CloneToUninit` dyn-compatibleZachary S-4/+4
2024-10-29Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`Eduardo Sánchez Muñoz-0/+27
2024-09-25Use `&raw` in the standard libraryJosh Stone-2/+1
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-19[Clippy] Swap `redundant_clone` to use diagnostic items instead of pathsGnomedDev-0/+1
2024-09-19[Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of pathsGnomedDev-0/+1
2024-09-05fix: correct {Path,OsStr}::to_string_lossy() docsRyosuke Takahashi-1/+1
2024-07-29Sparkle some attributes over `CloneToUninit` stuffPavel Grigorenko-0/+1
2024-07-29impl CloneToUninit for Path and OsStrPavel Grigorenko-0/+12
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-22Fix some `#[cfg_attr(not(doc), repr(..))]`Pavel Grigorenko-4/+2
Now that #90435 seems to have been resolved.
2024-07-14std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_uncheckedJubilee Young-2/+2
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-5/+10
#126333
2024-06-25inner truncate methods for UEFI platformsash-0/+5
2024-06-04impl OsString::leak & PathBuf::leakschvv31n-0/+19
2024-04-26PathBuf: replace transmuting by accessor functionsRalf Jung-0/+6
2024-04-17Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnayMatthias Krüger-0/+4
Document overrides of `clone_from()` in core/std As mentioned in https://github.com/rust-lang/rust/pull/96979#discussion_r1379502413 Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source". I reused some of the wording over and over for similar impls, but I'm not sure that the wording is actually *good*. Would appreciate feedback about that. Also, now some of these seem to provide pretty specific guarantees about behavior (e.g. will reuse the exact same allocation iff the len is the same), but I was basing it off of the docs for [`Box::clone_from`](https://doc.rust-lang.org/1.75.0/std/boxed/struct.Box.html#method.clone_from-1) - I'm not sure if providing those strong guarantees is actually good or not.
2024-03-08Document overrides of `clone_from()`Noa-0/+4
Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source".
2024-03-07Rust is a proper name: rust → RustRalf Jung-4/+4
2024-02-28Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-seGuillaume Gomez-3/+64
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see https://github.com/rust-lang/libs-team/issues/326#issuecomment-1894160023). - ACP: https://github.com/rust-lang/libs-team/issues/326 - Tracking issue: #120048
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-0/+1
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2024-01-21Move `OsStr::slice_encoded_bytes` validation to platform modulesJan Verbeek-35/+8
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-18Add `display` method to `OsStr`riverbl-3/+64
Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public.
2023-12-02Add substring API for `OsStr`Jan Verbeek-2/+80
2023-10-03Bump version placeholdersMark Rousskov-4/+4
2023-09-01fix(std): Rename os_str_bytes to encoded_bytesEd Page-28/+28
2023-09-01feat(std): Stabilize 'os_str_bytes' featureEd Page-8/+4
Closes #111544
2023-08-14actually this doesn't even affect doctests. nice.Ralf Jung-6/+3
2023-08-14std: add some missing repr(transparent)Ralf Jung-0/+3
2023-07-22Rollup merge of #113442 - epage:osstring, r=cuviperMatthias Krüger-0/+65
Allow limited access to `OsString` bytes This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-12Replace version placeholder to 1.72Mark Rousskov-1/+1
2023-07-07Allow limited access to `OsString` bytesEd Page-0/+65
This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.