about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-33/+32
2020-04-14Rollup merge of #71133 - MiSawa:fix-sort-by-key-doc, r=Dylan-DPCDylan DPC-1/+1
Tighten time complexity on the doc of sort_by_key Fixes #71132
2020-04-14Rollup merge of #70949 - WaffleLapkin:simlify_vec_macro, r=petrochenkovDylan DPC-3/+2
simplify `vec!` macro Simplify `vec!` macro by replacing 2 following branches: - `($($x:expr),*) => (...)` - `($($x:expr,)*) => (...)` with one: - `($($x:expr),* $(,)?) => (...)` This is a minor change, however, this will make the documentation cleaner
2020-04-14Vec drop and truncate: drop using raw slice *mut [T]Ulrik Sverdrup-2/+2
By creating a *mut [T] directly (without going through &mut [T]), avoid questions of validity of the contents of the slice. Consider the following risky code: ```rust unsafe { let mut v = Vec::<bool>::with_capacity(16); v.set_len(16); } ``` The intention is that with this change, the above snippet will be sound because Vec::drop does no longer produces a mutable slice of the vector's contents.
2020-04-14Tighten time complexity on the docmi_sawa-1/+1
2020-04-14Rollup merge of #71121 - AnthonyMikh:fix_string_doc_link, r=Dylan-DPCDylan DPC-0/+1
Fix broken link in documentation for String::from_utf8
2020-04-14Fix broken link in documentation for String::from_utf8AnthonyMikh-0/+1
2020-04-14make `vec![,]` uncompilableWaffle-2/+2
Fix regression introduced in commit #3ae2d21
2020-04-13weak-into-raw: as_raw -> as_ptr + dangling garbageMichal 'vorner' Vaner-52/+30
* Rename Weak::as_raw to Weak::as_ptr for consistency with some other types. * The as_ptr for a dangling Weak pointer might return whatever garbage (and takes that advantage to avoid a conditional). * Don't guarantee to be able to do `Weak::from_raw(weak.as_ptr())` (even though it'll still work fine).
2020-04-13Add examples to Pattern docsIvan Tham-0/+6
2020-04-13Add period to Pattern docsIvan Tham-1/+1
2020-04-11Rollup merge of #70996 - ChaiTRex:master, r=AmanieuDylan DPC-0/+28
Add or_insert_with_key to Entry of HashMap/BTreeMap Going along with `or_insert_with`, `or_insert_with_key` provides the `Entry`'s key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda. --- I'm fairly new to Rust, so any optimizations, corrections to types, better names, better documentation, or whatever else would be appreciated. I'd like to thank Arnavion on freenode for helping me to implement a very similar method when I found that `or_insert_with_key` was unavailable. As a somewhat-related note, this implements https://github.com/rust-lang/rfcs/issues/1202 from 2015, so if this pull request is accepted, that should be closed.
2020-04-11Change issue number to point to tracking issueChai T. Rex-1/+1
2020-04-10Fixed doc tests for added methodsChai T. Rex-0/+1
2020-04-10Add or_insert_with_key to Entry of HashMap/BTreeMapChai T. Rex-0/+27
Going along with or_insert_with, or_insert_with_key provides the Entry's key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time. This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.
2020-04-10Rollup merge of #70981 - ssomers:btreemap_into_into_iter, r=Mark-SimulacrumMazdak Farrokhzad-13/+13
Rearrange BTreeMap::into_iter to match range_mut. r? @Mark-Simulacrum I wondered why you catered for the optional root differently in `into_iter` than in `range_mut`.
2020-04-10Rollup merge of #70979 - ssomers:btreemap_the_alice_merton_variations, r=AmanieuMazdak Farrokhzad-4/+2
Follow up on BTreeMap comments r? @Amanieu (for the first commit)
2020-04-10Rollup merge of #70913 - eddyb:rc-arc-diagnostic-items, r=matthewjasperMazdak Farrokhzad-2/+4
Replace "rc"/"arc" lang items with Rc/Arc diagnostic items. `Rc`/`Arc` should have no special semantics, so it seems appropriate for them to not be lang items. r? @matthewjasper
2020-04-10Rollup merge of #70843 - ssomers:btree_drain_filter_epilogue, r=AmanieuMazdak Farrokhzad-45/+21
Remove the Ord bound that was plaguing drain_filter Now that #70795 made it superfluous. Also removes superfluous lifetime specifiers (at least I think they are).
2020-04-10Rearrange BTreeMap::into_iter to match range_mut.Stein Somers-13/+13
2020-04-09Respect the comment: no root unless the borrow type is `Mut`Stein Somers-2/+2
2020-04-09Kill comment left behind by a last minute change in #70795Stein Somers-2/+0
2020-04-09Rollup merge of #70958 - Amanieu:android_try_reserve, r=Mark-SimulacrumMazdak Farrokhzad-0/+6
Disable try_reserve tests on Android Calling `realloc` with large sizes seems to be broken on older Android versions that use dlmalloc as the default allocator. This is not an issue for modern Android versions that use jemalloc. Fixes #55861
2020-04-09Disable try_reserve tests on AndroidAmanieu d'Antras-0/+6
2020-04-09simplify `vec!` macroWaffle-2/+1
Simplify `vec!` macro by replacing 2 following branches: - `($($x:expr),*) => (...)` - `($($x:expr,)*) => (...)` with one: - `($($x:expr),* $(,)?) => (...)`
2020-04-08Rollup merge of #70930 - lcnr:patch-1, r=Dylan-DPCDylan DPC-1/+1
add tracking issue to `VecDeque::make_contiguous` The tracking issue is https://github.com/rust-lang/rust/issues/70929
2020-04-08Rollup merge of #70565 - Zoxc:inlines-query-system, r=davidtwcoDylan DPC-0/+1
Add inline attributes for functions used in the query system
2020-04-08Rollup merge of #70850 - ssomers:btreemap_first_last, r=AmanieuDylan DPC-48/+76
BTreeMap first last proposal tweaks Clean-up and following up on a request in #62924. Trying the reviewer of the original code #65637... r? @scottmcm
2020-04-08add `VecDeque::make_contiguous` tracking issueBastian Kauschke-1/+1
2020-04-08Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.Eduard-Mihai Burtescu-2/+4
2020-04-07Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnayDylan DPC-4/+4
Don't import integer and float modules, use assoc consts 2 Follow up to #70777. I missed quite a lot of places. Partially because I wanted to keep the size of the last PR down, and partially because my regexes were not good enough :) r? @dtolnay
2020-04-06Use split_at in slice's ToOwned::clone_intoJosh Stone-6/+6
It appears to codegen slightly more efficiently with `split_at` taking two slices at once, rather than slicing across different calls.
2020-04-06Use usize::MAX as assoc const in liballocLinus Färnstrand-2/+2
2020-04-06Use assoc const f32::NAN in liballocLinus Färnstrand-2/+2
2020-04-06BTreeMap first/last: add pop methodsStein Somers-0/+48
2020-04-06BTreeMap first/last: make examples more to the pointStein Somers-10/+12
2020-04-06BTreeMap first/last: simplify implementationsStein Somers-38/+16
2020-04-06add detailed panic messages for Vec functionsIgorPerikov-6/+55
2020-04-06Remove the Ord bound that was plaguing drain_filter, and superfluous lifetimesStein Somers-45/+21
2020-04-05Rollup merge of #70795 - Amanieu:btree_remove_tracking, r=Mark-SimulacrumDylan DPC-49/+64
Keep track of position when deleting from a BTreeMap This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap. cc @ssomers r? @Mark-Simulacrum
2020-04-05Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnayDylan DPC-10/+0
Don't import integer and float modules, use assoc consts Stop importing the standard library integer and float modules to reach the `MIN`, `MAX` and other constants. They are available directly on the primitive types now. This PR is a follow up of #69860 which made sure we use the new constants in documentation. This type of change touches a lot of files, and previously all my assoc int consts PRs had collisions and were accepted only after a long delay. So I'd prefer to do it in smaller steps now. Just removing these imports seem like a good next step. r? @dtolnay
2020-04-05Apply review feedbackAmanieu d'Antras-15/+10
2020-04-05Keep track of position when deleting from a BTreeMapAmanieu d'Antras-39/+59
This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap.
2020-04-05Rollup merge of #70776 - RalfJung:raw-vec, r=Dylan-DPC,TimDiekmannDylan DPC-3/+6
clarify comment in RawVec::into_box On first reading I almost thought "len <= cap" would be all that there is to check here. Expand the comment to clarify that that is not the case.
2020-04-05Rollup merge of #70558 - RalfJung:vec-extend-aliasing, r=AmanieuDylan DPC-14/+79
Fix some aliasing issues in Vec `Vec::extend` and `Vec::truncate` invalidated references into the vector even without reallocation, because they (implicitly) created a mutable reference covering the *entire* initialized part of the vector. Fixes https://github.com/rust-lang/rust/issues/70301 I verified the fix by adding some new tests here that I ran in Miri.
2020-04-05clarify safety in RawVec::into_boxRalf Jung-3/+6
2020-04-05Stop importing integer modules in liballocLinus Färnstrand-10/+0
2020-04-05tweak swap_removeRalf Jung-3/+4
2020-04-04use ManuallyDrop instead of forget inside collectionsTrevor Spiteri-38/+34
This commit changes some usage of mem::forget into mem::ManuallyDrop in some Vec, VecDeque, BTreeMap and Box methods. Before the commit, the generated IR for some of the methods was longer, and even after optimization, some unwinding artifacts were still present.
2020-04-03Rollup merge of #69860 - faern:use-assoc-int-consts, r=dtolnayMazdak Farrokhzad-2/+2
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of #67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.