about summary refs log tree commit diff
path: root/library/alloc/src/borrow.rs
AgeCommit message (Collapse)AuthorLines
2025-03-07Fully test the alloc crate through alloctestsbjorn3-3/+3
For the tests that make use of internal implementation details, we include the module to test using #[path] in alloctests now.
2025-02-15Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.Zachary S-1/+11
2024-10-12remove const_cow_is_borrowed feature gateRalf Jung-2/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-04-05Impl `DerefPure` for more std typesNadrieril-1/+4
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+1
2023-05-07enable `rust_2018_idioms` for doctestsozkanonur-4/+4
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-03-28Remove ~const from allocJubilee Young-3/+2
2022-07-22Remove redundant lifetime bound from `impl Borrow for Cow`Frank Steffahn-1/+0
The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference, because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types will outlive lifetimes outlived by the `Self` type (and all the trait's generic parameters, of which there are none in this case), so the implicit `B: 'a` implies `B::Owned: 'a` anyway. The explicit lifetime bound here does however end up in documentation, and that's confusing in my opinion, so let's remove it ^^
2022-07-08Intra-doc-link-ify reference to Clone::clone_fromest31-1/+1
2022-05-28Stabilize `toowned_clone_into`Yuki Okushi-2/+1
2022-04-26Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPCGuillaume Gomez-3/+3
Clarify that `Cow::into_owned` returns owned data Two sections of the `Cow::into_owned` docs imply that `into_owned` returns a `Cow`. Clarify that it returns the underlying owned object, either cloned or extracted from the `Cow`.
2022-04-05trivial cfg(bootstrap) changesPietro Albini-1/+0
2022-03-23Clarify that `Cow::into_owned` returns owned dataJonathan Giddy-3/+3
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-0/+1
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-12-18docs: fix typoSzilárd Parrag-1/+1
Add missing `'s` to ` Let check it out.`
2021-09-15Const DerefDeadbeef-1/+5
2021-07-15Added diagnostic items to structs and traits for ClippyxFrednet-0/+1
2021-05-05alloc: Add unstable Cfg feature `no-global_oom_handling`John Ericson-1/+8
For certain sorts of systems, programming, it's deemed essential that all allocation failures be explicitly handled where they occur. For example, see Linus Torvald's opinion in [1]. Merely not calling global panic handlers, or always `try_reserving` first (for vectors), is not deemed good enough, because the mere presence of the global OOM handlers is burdens static analysis. One option for these projects to use rust would just be to skip `alloc`, rolling their own allocation abstractions. But this would, in my opinion be a real shame. `alloc` has a few `try_*` methods already, and we could easily have more. Features like custom allocator support also demonstrate and existing to support diverse use-cases with the same abstractions. A natural way to add such a feature flag would a Cargo feature, but there are currently uncertainties around how std library crate's Cargo features may or not be stable, so to avoid any risk of stabilizing by mistake we are going with a more low-level "raw cfg" token, which cannot be interacted with via Cargo alone. Note also that since there is no notion of "default cfg tokens" outside of Cargo features, we have to invert the condition from `global_oom_handling` to to `not(no_global_oom_handling)`. This breaks the monotonicity that would be important for a Cargo feature (i.e. turning on more features should never break compatibility), but it doesn't matter for raw cfg tokens which are not intended to be "constraint solved" by Cargo or anything else. To support this use-case we create a new feature, "global-oom-handling", on by default, and put the global OOM handler infra and everything else it that depends on it behind it. By default, nothing is changed, but users concerned about global handling can make sure it is disabled, and be confident that all OOM handling is local and explicit. For this first iteration, non-flat collections are outright disabled. `Vec` and `String` don't yet have `try_*` allocation methods, but are kept anyways since they can be oom-safely created "from parts", and we hope to add those `try_` methods in the future. [1]: https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/
2021-02-16a few more diagnostic itemsAndrea Nall-1/+1
2021-02-15requested/proposed changesAndrea Nall-1/+1
2021-02-15add diagnostic itemsAndrea Nall-0/+1
Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2020-12-28Mention Arc::make_mut and Rc::make_mut in the documentation of CowFrank Steffahn-0/+5
2020-09-22Update library functions with stability attributesDylan MacKenzie-0/+2
This may not be strictly minimal, but all unstable functions also need a `rustc_const_unstable` attribute.
2020-08-31Make `cow_is_borrowed` methods constCDirkx-2/+2
Constify the following methods of `alloc::borrow::Cow`: - `is_borrowed` - `is_owned` These methods are still unstable under `cow_is_borrowed`. Possible because of #49146 (Allow if and match in constants). Tracking issue: #65143
2020-07-27mv std libs to library/mark-0/+476