about summary refs log tree commit diff
path: root/src/liballoc/tests/lib.rs
AgeCommit message (Collapse)AuthorLines
2020-04-24Add BinaryHeap::retain as suggested in #42849arlo-0/+1
2020-03-29BTreeMap/BTreeSet: implement and test drain_filterStein Somers-0/+1
2020-02-09Implement split_inclusive for slice and str, an splitting iterator that ↵Pyry Kontio-0/+1
includes the matched part in the iterated substrings as a terminator.
2020-01-11Revert "Rollup merge of #67727 - Dylan-DPC:stabilise/remove_item, ↵Lzu Tao-0/+1
r=alexcrichton" This reverts commit 4ed415b5478c74094c2859abfddb959588cd6bb1, reversing changes made to 3cce950743e8aa74a4378dfdefbbc80223a00865.
2020-01-06oh the one that was left behinddylan_DPC-1/+0
2020-01-05add feature gatedylan_DPC-0/+1
2019-12-22Format the worldMark Rousskov-2/+2
2019-11-13Auto merge of #65637 - ssomers:master, r=scottmcmbors-0/+1
proposal for BTreeMap/Set min/max, #62924 - Which pair of names: #62924 lists the existing possibilities min/max, first/last, (EDIT) front/back, peek(/peek_back?). Iterators have next/next_back or next/last. I'm slightly in favour of first/last because min/max might suggest they search over the entire map, and front/back pretends they are only about position. - Return key only instead of pair like iterator does? - If not, then keep the _key_value suffix? ~~Also provide variant with mutable value? But there is no such variant for get_key_value.~~ - Look for and upgrade more usages of `.iter().next()` and such in the libraries? I only upgraded the ones I contributed myself, all very recently.
2019-10-31Auto merge of #65091 - sekineh:into-iter-sorted, r=KodrAusbors-0/+2
Implement ordered/sorted iterators on BinaryHeap as per #59278 I've implemented the ordered version of iterator on BinaryHeap as per #59278. # Added methods: * `.into_iter_sorted()` * like `.into_iter()`; but returns elements in heap order * `.drain_sorted()` * like `.drain()`; but returns elements in heap order * It's a bit _lazy_; elements are removed on drop. (Edit: it’s similar to vec::Drain) For `DrainSorted` struct, I implemented `Drop` trait following @scottmcm 's [suggestion](https://github.com/rust-lang/rust/issues/59278#issuecomment-537306925) # ~TODO~ DONE * ~I think I need to add more tests other than doctest.~ # **Notes:** * we renamed `_ordered` to `_sorted`, because the latter is more common in rust libs. (as suggested by @KodrAus )
2019-10-25Add .into_iter_sorted() and .drain_sorted()Hideki Sekine-0/+2
* `.drain_sorted()` doc change suggested by @KodrAus
2019-10-23proposal for access to BTreeMap/BTreeSet first/last, #62924Stein Somers-0/+1
2019-10-19Stabilize `Option::flatten`Ethan Brierley-1/+0
2019-10-19Rollup merge of #65174 - SimonSapin:zero-box, r=alexcrichtonMazdak Farrokhzad-0/+2
Fix zero-size uninitialized boxes Requesting a zero-size allocation is not allowed, return a dangling pointer instead. CC https://github.com/rust-lang/rust/issues/63291#issuecomment-538692745
2019-10-18Uninitialized boxes: add test for zero-size allocationsSimon Sapin-0/+2
2019-10-02Stabilize `slice::repeat` (feature `repeat_generic_slice`)Lzu Tao-1/+0
2019-08-09Add missing #![feature(associated_type_bounds)]Ilija Tovilo-0/+1
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-1/+0
rustbuild Remove some random unnecessary lint `allow`s
2019-06-21shared_from_iter: Add more tests.Mazdak Farrokhzad-0/+2
2019-05-09make vecdeque_rotate stableDodo-1/+0
2019-04-20Deny rust_2018_idioms in liballoc testsPhilipp Hansch-0/+1
2019-02-25Remove some unnecessary 'extern crate'Taiki Endo-3/+0
2019-02-12Stabilize slice_sort_by_cached_keyScott McMurray-1/+0
2019-02-12Stabilize str::escape_* methodsSimon Sapin-1/+0
FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-19Add more VecDeque::rotate_{left|right} testsScott McMurray-1/+2
2018-11-11std: Delete the `alloc_system` crateAlex Crichton-2/+0
This commit deletes the `alloc_system` crate from the standard distribution. This unstable crate is no longer needed in the modern stable global allocator world, but rather its functionality is folded directly into the standard library. The standard library was already the only stable location to access this crate, and as a result this should not affect any stable code.
2018-10-31Bump nightly to 1.32.0Alex Crichton-1/+0
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-18Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()Sebastian Dröge-1/+0
Fixes #55177
2018-10-18Stabilize slice::chunks_exact() and slice::chunks_exact_mut()Sebastian Dröge-1/+0
Fixes #47115
2018-10-18Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()Sebastian Dröge-0/+1
These work exactly like the normal chunks iterators but start creating chunks from the end of the slice. See #55177 for the tracking issue
2018-10-05Stabilize `min_const_fn`Oliver Schneider-1/+1
2018-09-27Bump to 1.31.0 and bootstrap from 1.30 betaJosh Stone-2/+1
2018-09-24Rename slice::exact_chunks() to slice::chunks_exact()Sebastian Dröge-1/+1
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-08-31Restrict most uses of `const_fn` to `min_const_fn`Oliver Schneider-1/+2
2018-08-23Stabilize 'attr_literals' feature.Sergio Benitez-1/+0
2018-08-05Fix stage 2 testsvarkor-2/+0
2018-08-05Remove unnecessary or invalid feature attributesvarkor-1/+0
2018-07-28Rollup merge of #52769 - sinkuu:stray_test, r=alexcrichtonkennytm-0/+1
Incorporate a stray test `liballoc/repeat-generic-slice.rs` doesn't seem to be tested (I think it was intended to be placed in `run-pass`). This PR incorporates the test into `liballoc/tests`.
2018-07-27Incorporate a stray testShotaro Yamada-0/+1
2018-07-25Add missing dynTatsuyuki Ishi-1/+1
2018-07-07Add some unit tests for dangling Weak referencesSimon Sapin-0/+2
2018-06-02Stabilize Iterator::step_byThayne McCombs-1/+0
Fixes #27741
2018-05-17Stabilise inclusive_range_methodsvarkor-1/+0
2018-04-30Make the fields of RangeInclusive private.kennytm-1/+1
Added new()/start()/end() methods to RangeInclusive. Changed the lowering of `..=` to use RangeInclusive::new().
2018-04-12Mark the rest of the `unicode` feature flag as perma-unstable.Simon Sapin-1/+0
2018-04-12Deprecate the std_unicode crateSimon Sapin-1/+1
2018-04-08Move deny(warnings) into rustbuildMark Simulacrum-2/+0
This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-1/+0
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-2/+0
Closes #22181, #27779
2018-03-27Rollup merge of #48639 - varkor:sort_by_key-cached, r=blusskennytm-0/+1
Add slice::sort_by_cached_key as a memoised sort_by_key At present, `slice::sort_by_key` calls its key function twice for each comparison that is made. When the key function is expensive (which can often be the case when `sort_by_key` is chosen over `sort_by`), this can lead to very suboptimal behaviour. To address this, I've introduced a new slice method, `sort_by_cached_key`, which has identical semantic behaviour to `sort_by_key`, except that it guarantees the key function will only be called once per element. Where there are `n` elements and the key function is `O(m)`: - `slice::sort_by_cached_key` time complexity is `O(m n log m n)`, compared to `slice::sort_by_key`'s `O(m n + n log n)`. - `slice::sort_by_cached_key` space complexity remains at `O(n + m)`. (Technically, it now reserves a slice of size `n`, whereas before it reserved a slice of size `n/2`.) `slice::sort_unstable_by_key` has not been given an analogue, as it is important that unstable sorts are in-place, which is not a property that is guaranteed here. However, this also means that `slice::sort_unstable_by_key` is likely to be slower than `slice::sort_by_cached_key` when the key function does not have negligible complexity. We might want to explore this trade-off further in the future. Benchmarks (for a vector of 100 `i32`s): ``` # Lexicographic: `|x| x.to_string()` test bench_sort_by_key ... bench: 112,638 ns/iter (+/- 19,563) test bench_sort_by_cached_key ... bench: 15,038 ns/iter (+/- 4,814) # Identity: `|x| *x` test bench_sort_by_key ... bench: 1,346 ns/iter (+/- 238) test bench_sort_by_cached_key ... bench: 1,839 ns/iter (+/- 765) # Power: `|x| x.pow(31)` test bench_sort_by_key ... bench: 3,624 ns/iter (+/- 738) test bench_sort_by_cached_key ... bench: 1,997 ns/iter (+/- 311) # Abs: `|x| x.abs()` test bench_sort_by_key ... bench: 1,546 ns/iter (+/- 174) test bench_sort_by_cached_key ... bench: 1,668 ns/iter (+/- 790) ``` (So it seems functions that are single operations do perform slightly worse with this method, but for pretty much any more complex key, you're better off with this optimisation.) I've definitely found myself using expensive keys in the past and wishing this optimisation was made (e.g. for https://github.com/rust-lang/rust/pull/47415). This feels like both desirable and expected behaviour, at the small cost of slightly more stack allocation and minute degradation in performance for extremely trivial keys. Resolves #34447.