about summary refs log tree commit diff
path: root/library/alloc/src
AgeCommit message (Collapse)AuthorLines
2024-02-16reduce branchinessLukas Markeffsky-31/+22
2024-02-16reduce amount of mathLukas Markeffsky-14/+12
2024-02-16simplify codegen for trivially droppable typesLukas Markeffsky-2/+3
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-26/+27
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Fix typo in VecDeque::handle_capacity_increase() doc comment.Johannes Lade-4/+4
Strategies B and C both show a full buffer before the capacity increase, while strategy A had one empty element left. Filled the last element in.
2024-02-15Add slice::try_rangeltdk-2/+2
2024-02-15Rollup merge of #120505 - Amanieu:fix-btreemap-cursor-remove, r=m-ou-seGuillaume Gomez-0/+12
Fix BTreeMap's Cursor::remove_{next,prev} These would incorrectly leave `current` as `None` after a failed attempt to remove an element (due to the cursor already being at the start/end).
2024-02-15Rollup merge of #120449 - udoprog:document-unsized-rc-arc-from-raw, r=m-ou-seGuillaume Gomez-26/+122
Document requirements for unsized {Rc,Arc}::from_raw This seems to be implied due to these types supporting operation-less unsized coercions. Taken together with the [established behavior of a wide to thin pointer cast](https://github.com/rust-lang/reference/pull/1451) it would enable unsafe downcasting of these containers. Note that the term "data pointer" is adopted from https://github.com/rust-lang/rfcs/pull/3559 See also this [internals thread](https://internals.rust-lang.org/t/can-unsafe-smart-pointer-downcasts-be-correct/20229/2).
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-9/+9
2024-02-15Use generic `NonZero` internally.Markus Reiter-26/+27
2024-02-14Rollup merge of #116387 - kpreid:wake-doc, r=cuviperOli Scherer-3/+10
Additional doc links and explanation of `Wake`. This is intended to clarify: * That `Wake` exists and can be used instead of `RawWaker`. * How to construct a `Waker` when you are looking at `Wake` (which was previously only documented in the example).
2024-02-13Rollup merge of #120967 - LeoDog896:master, r=cuviperMatthias Krüger-0/+16
docs: mention round-to-even in precision formatting _Note_: Not quite sure exactly how to format this documentation. Mentions round-to-even usage in precision formatting. (should this also be mentioned in `f64::round`?) From https://github.com/rust-lang/rust/issues/70336
2024-02-12docs: use correct link, use secondary exampleTristan F-2/+5
2024-02-12Rollup merge of #120936 - ripytide:master, r=AmanieuMatthias Krüger-85/+128
improve `btree_cursors` functions documentation As suggested by ``@Amanieu`` (and others) in #107540 (https://github.com/rust-lang/rust/issues/107540#issuecomment-1937760547) Improvements: - Document exact behavior of `{upper/lower}_bound{,_mut}` with each of the three `Bound` types using unambigous words `{greatest,greater,smallest,smaller,before,after}`. - Added another doc-example for the `Bound::Unbounded` for each of the methods - Changed doc-example to use From<[T; N]> rather than lots of `insert()`s which requires a mutable map which clutters the example when `mut` may not be required for the method (such as for `{upper,lower}_bound`. - Removed `# Panics` section from `insert_{before,after}` methods since they were changed to return an error instead a while ago. - Reworded some phrases to be more consistent with the more regular `BTreeMap` methods such as calling entries "key-value" rather than "element"s.
2024-02-12style: fmtTristan F.-1/+1
2024-02-12docs: mention round-to-even in precision formattingTristan F-0/+13
2024-02-11Rollup merge of #110483 - tleibert:thin-box-try-new, r=dtolnayMatthias Krüger-0/+64
Create try_new function for ThinBox The `allocator_api` feature has proven very useful in my work in the FreeBSD kernel. I've found a few places where a `ThinBox` #92791 would be useful, but it must be able to be fallibly allocated for it to be used in the kernel. This PR proposes a change to add such a constructor for ThinBox. ACP: https://github.com/rust-lang/libs-team/issues/213
2024-02-11fix intra-doc linksripytide-12/+12
2024-02-11Address ThinBox::try_new PR reviewDavid Tolnay-4/+3
2024-02-11fix incorrect doctestripytide-2/+2
2024-02-11improve `btree_cursors` functions documentationripytide-87/+130
2024-02-11Rollup merge of #117740 - majaha:format_docs, r=joshtriplettMatthias Krüger-0/+5
Add some links and minor explanatory comments to `std::fmt` I thought the documentation for the `#` flag could do with a link to the explanation of the `?xXbo` flags, because at that point they haven't been explained yet and it's a bit confusing. I also added that the `0` flag overrides the fill character and alignment flag, here's a [Rust Playgrond](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0d580b7b78b8a2d8c08a2fc7a936ef17) that shows what I mean.
2024-02-10Remove the link.Kevin Reid-4/+5
2024-02-10URL-encode chars in fragment.Kevin Reid-1/+1
2024-02-10Additional doc links and explanation of `Wake`.Kevin Reid-3/+9
This is intended to clarify: * That `Wake` exists and can be used instead of `RawWaker`. * How to construct a `Waker` when you are looking at `Wake` (which was previously only documented in the example).
2024-02-10Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obkbors-0/+30
Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits This PR implements several changes to the built-in and libcore-provided implementations of `Fn*` and `AsyncFn*` to address two problems: 1. async closures do not implement the `Fn*` family traits, leading to breakage: https://crater-reports.s3.amazonaws.com/pr-120361/index.html 2. *references* to async closures do not implement `AsyncFn*`, as a consequence of the existing blanket impls of the shape `AsyncFn for F where F: Fn, F::Output: Future`. In order to fix (1.), we implement `Fn` traits appropriately for async closures. It turns out that async closures can: * always implement `FnOnce`, meaning that they're drop-in compatible with `FnOnce`-bound combinators like `Option::map`. * conditionally implement `Fn`/`FnMut` if they have no captures, which means that existing usages of async closures should *probably* work without breakage (crater checking this: https://github.com/rust-lang/rust/pull/120712#issuecomment-1930587805). In order to fix (2.), we make all of the built-in callables implement `AsyncFn*` via built-in impls, and instead adjust the blanket impls for `AsyncFn*` provided by libcore to match the blanket impls for `Fn*`.
2024-02-09Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789bors-2/+2
Bump bootstrap compiler to just-built 1.77 beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-02-08Reduce use of NonNull::new_unchecked in library/Ben Kimock-10/+11
2024-02-08Bump version placeholdersMark Rousskov-2/+2
2024-02-06Harmonize blanket implementations for AsyncFn* traitsMichael Goulet-0/+30
2024-02-05Rollup merge of #118960 - tvallotton:local_waker, r=Mark-SimulacrumMatthias Krüger-6/+182
Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc. Implementation for #118959.
2024-02-05Rollup merge of #113833 - WiktorPrzetacznik:master, r=dtolnayMatthias Krüger-8/+8
`std::error::Error` -> Trait Implementations: lifetimes consistency improvement This cleans up `std::error::Error` trait implementations lifetime inconsistency (`'static` -> `'a`) **Reasoning:** Trait implementations for `std::error::Error`, like: `impl From<&str> for Box<dyn Error + 'static, Global>` `impl<'a> From<&str> for Box<dyn Error + Sync + Send + 'a, Global>` use different lifetime annotations misleadingly implying using different life annotations here is a conscious, nonaccidental decision. [(Related forum discussion here)](https://users.rust-lang.org/t/confusing-std-error-source-code/97011/5?u=wiktor)
2024-02-05Rollup merge of #120458 - rytheo:cstr-conversion-doc, r=Mark-SimulacrumMatthias Krüger-0/+2
Document `&CStr` to `CString` conversion Related to #51430
2024-01-31Rollup merge of #120355 - the8472:doc-vec-fromiter, r=cuviperNadrieril-0/+44
document `FromIterator for Vec` allocation behaviors [t-libs discussion](https://rust-lang.zulipchat.com/#narrow/stream/259402-t-libs.2Fmeetings/topic/Meeting.202024-01-24/near/417686526) about #120091 didn't reach a strong consensus, but it was agreed that if we keep the current behavior it should at least be documented even though it is an implementation detail. The language is intentionally non-committal. The previous (non-existent) documentation permits a lot of implementation leeway and we want retain that. In some cases we even must retain it to be able to rip out some code paths that rely on unstable features.
2024-01-30Apply suggestions from code reviewthe8472-12/+11
Co-authored-by: Josh Stone <cuviper@gmail.com>
2024-01-30document `FromIterator for Vec` allocation behaviorsThe 8472-0/+45
2024-01-30Fix BTreeMap's Cursor::remove_{next,prev}Amanieu d'Antras-0/+12
These would incorrectly leave `current` as `None` after a failed attempt to remove an element (due to the cursor already being at the start/end).
2024-01-30Rollup merge of #120445 - Nemo157:arc-plug, r=Mark-SimulacrumGuillaume Gomez-29/+80
Fix some `Arc` allocator leaks This doesn't matter for the stable `Global` allocator as it is a ZST singleton, but other allocators may rely on all instances being dropped.
2024-01-29Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-SimulacrumDylan DPC-5/+12
Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from https://github.com/rust-lang/rust/issues/106894#issuecomment-1905627234. Rendered: ![Screenshot_20240123_114436](https://github.com/rust-lang/rust/assets/3986214/68896d62-13e0-4f3a-8073-91d8e77c5554) ![Screenshot_20240123_114455](https://github.com/rust-lang/rust/assets/3986214/dc58e4bd-dd7f-40b1-bc50-fd6200dde593)
2024-01-28Document From<&CStr> for CStringRyan Lowe-0/+2
2024-01-28Fix some `Arc` allocator leaksWim Looman-29/+80
This doesn't matter for the stable `Global` allocator as it is a ZST singleton, but other allocators may rely on all instances being dropped.
2024-01-28Fix doctestJohn-John Tedro-4/+6
2024-01-28Replicate documentation in {Rc,Arc}::from_raw_inJohn-John Tedro-16/+66
2024-01-28Fix doctestJohn-John Tedro-4/+4
2024-01-28Tidy upJohn-John Tedro-2/+2
2024-01-28Add examples for unsized {Rc,Arc}::from_rawJohn-John Tedro-0/+28
2024-01-28Document requirements for unsized {Rc,Arc}::from_rawJohn-John Tedro-12/+28
2024-01-26Rollup merge of #113489 - tguichaoua:cow_from_array, r=dtolnayMatthias Krüger-0/+13
impl `From<&[T; N]>` for `Cow<[T]>` Implement `From<&[T; N]>` for `Cow<[T]>` to simplify its usage in the following example. ```rust fn foo(data: impl Into<Cow<'static, [&'static str]>>) { /* ... */ } fn main() { foo(vec!["hello", "world"]); foo(&["hello", "world"]); // Error: the trait `From<&[&str; 2]>` is not implemented for `Cow<'static, [&'static str]>` foo(&["hello", "world"] as &[_]); // Explicit convertion into a slice is required } ```
2024-01-26Rollup merge of #103522 - Dylan-DPC:76118/array-methods-stab, r=dtolnayMatthias Krüger-1/+0
stabilise array methods Closes #76118 Stabilises the remaining array methods FCP is yet to be carried out for this There wasn't a clear consensus on the naming, but all the other alternatives had some flaws as discussed in the tracking issue and there was a silence on this issue for a year
2024-01-26Rollup merge of #120372 - bjorn3:fix_outdated_comment, r=NilstriebMatthias Krüger-2/+1
Fix outdated comment on Box Caught by `@vi` in https://github.com/rust-lang/rust/pull/113960#discussion_r1454278520