about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2017-05-04Deprecate heap::EMPTY in favour of Unique::empty or otherwise.Alexis Beingessner-3/+4
2017-05-04fallout from NonZero/Unique/Shared changesAlexis Beingessner-47/+60
2017-05-04Make [u8]::reverse() 5x fasterScott McMurray-0/+31
Since LLVM doesn't vectorize the loop for us, do unaligned reads of a larger type and use LLVM's bswap intrinsic to do the reversing of the actual bytes. cfg!-restricted to x86 and x86_64, as I assume it wouldn't help on things like ARMv5. Also makes [u16]::reverse() a more modest 1.5x faster by loading/storing u32 and swapping the u16s with ROT16. Thank you ptr::*_unaligned for making this easy :)
2017-04-28FromIterator and Extend Cow for StringEh2406-0/+18
2017-04-26Auto merge of #41258 - clarcharr:str_box_extras, r=Kimundibors-3/+14
More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes) This is a follow-up to #41096 that adds safer methods for converting between `Box<str>` and `Box<[u8]>`. They're gated under a different feature from the `&mut str` methods because they may be too niche to include in public APIs, although having them internally helps reduce the number of transmutes the standard library uses. What's added: * `From<Box<str>> for Box<[u8]>` * `<Box<str>>::into_boxed_bytes` (just calls `Into::into`) * `alloc::str` (new module) * `from_boxed_utf8` and `from_boxed_utf8_unchecked`, defined in `alloc:str`, exported in `collections::str` * exports `from_utf8_mut` in `collections::str` (missed from previous PR)
2017-04-25Rollup merge of #41535 - steveklabnik:gh37746, r=alexcrichtonCorey Farwell-1/+3
Fix up vec guarnatee around capacity Fixes #37746 r? @rust-lang/libs
2017-04-25Rollup merge of #41530 - GuillaumeGomez:vec-from, r=aturonCorey Farwell-0/+12
Implement From<&mut [T]> for Vec Fixes #41386.
2017-04-25Rollup merge of #41500 - steveklabnik:gh37866, r=frewsxcvCorey Farwell-1/+2
use the word 'length' in Vec::len's docs Fixes #37866
2017-04-25Fix up vec guarnatee around capacitysteveklabnik-1/+3
Fixes #37746
2017-04-25Implement From<&mut [T]> for VecGuillaume Gomez-0/+12
2017-04-24More methods for str boxes.Clar Charr-3/+14
2017-04-24Add Splice forget testMatt Ickstadt-0/+15
2017-04-24use the word 'length' in Vec::len's docssteveklabnik-1/+2
Fixes #37866
2017-04-23Use Vec::splice impl in string::Splice::drop()Matt Ickstadt-15/+1
2017-04-23Improve splice docs and testsMatt Ickstadt-4/+97
2017-04-23Update splice implMatt Ickstadt-6/+22
2017-04-23Add Vec::splice and String::spliceSimon Sapin-7/+313
2017-04-23Auto merge of #41437 - cuviper:remove-unstable-deprecated, r=alexcrichtonbors-438/+0
Remove items that are unstable and deprecated This removes unstable items that have been deprecated for more than one cycle. - Since 1.16.0, `#![feature(enumset)]` - All of `mod collections::enum_set` - Since 1.15.0, `#![feature(borrow_state)]` - `cell::BorrowState` - `RefCell::borrow_state()` - Since 1.15.0, `#![feature(is_unique)]` - `Rc::is_unique()` (made private like `Arc::is_unique()`) - Since 1.15.0, `#![feature(rc_would_unwrap)]` - `Rc::would_wrap()` - Since 1.13.0, `#![feature(binary_heap_extras)]` - `BinaryHeap::push_pop()` - `BinaryHeap::replace()` - Since 1.12.0, `#![feature(as_unsafe_cell)]` - `Cell::as_unsafe_cell()` - `RefCell::as_unsafe_cell()` - Since 1.12.0, `#![feature(map_entry_recover_keys)]` - `btree_map::OccupiedEntry::remove_pair()` - `hash_map::OccupiedEntry::remove_pair()` - Since 1.11.0, `#![feature(float_extras)]` - `Float::nan()` - `Float::infinity()` - `Float::neg_infinity()` - `Float::neg_zero()` - `Float::zero()` - `Float::one()` - `Float::integer_decode()` - `f32::integer_decode()` - `f32::ldexp()` - `f32::frexp()` - `f32::next_after()` - `f64::integer_decode()` - `f64::ldexp()` - `f64::frexp()` - `f64::next_after()` - Since 1.11.0, `#![feature(zero_one)]` - `num::Zero` - `num::One`
2017-04-22Fix invalid linkageGuillaume Gomez-5/+5
2017-04-20Remove OccupiedEntry::remove_pairJosh Stone-7/+0
[unstable, deprecated since 1.12.0]
2017-04-20Remove BinaryHeap::{push_pop,replace}Josh Stone-114/+0
[unstable, deprecated since 1.13.0]
2017-04-20Remove EnumSetJosh Stone-317/+0
[unstable, deprecated since 1.16.0]
2017-04-20Auto merge of #41342 - GuillaumeGomez:btree-debug-infinite, r=alexcrichtonbors-14/+26
Fix debug infinite loop Fixes #41338.
2017-04-20Auto merge of #41191 - seanmonstar:spec-extend-vec-intoiter, r=alexcrichtonbors-8/+41
specialize Extend for Vec with IntoIter Before, `vec.extend(&other_vec)` was quite a bit faster than `vec.extend(other_vec)`. This allows extending by consuming a vec to use the same code as extending from a slice.
2017-04-19Rollup merge of #41380 - ollie27:stability, r=BurntSushiCorey Farwell-1/+11
Fix a few stability attributes These show up in rustdoc so need to be correct.
2017-04-19specialize Extend for Vec with IntoIterSean McArthur-8/+41
2017-04-19Fix debug infinite loopGuillaume Gomez-14/+26
2017-04-18Fix a few stability attributesOliver Middleton-1/+11
These show up in rustdoc so need to be correct.
2017-04-18Rollup merge of #40290 - 3Hren:master, r=aturonCorey Farwell-0/+20
Add `as_bytes()` for `FromUtf8Error`. This change allows to obtain an underlying invalid UTF-8 bytes without `FromUtf8Error` destruction. Such method may be useful for example in a library that attempts to save both valid and invalid UTF-8 strings in some struct and to be able to provide immutable access to it without destruction. Personally without this change I ended with `Result<String, (Vec<u8>, Utf8Error)`, which almost copies the functionality of `FromUtf8Error`, but allows immutable view access.
2017-04-16Auto merge of #40409 - mbrubeck:calloc, r=sfacklerbors-3/+71
Specialize Vec::from_elem to use calloc Fixes #38723. This specializes the implementation for `u8` only, but it could be extended to other zeroable types if desired. I haven't tested this extensively, but I did verify that it gives the expected performance boost for large `vec![0; n]` allocations with both alloc_system and jemalloc, on Linux. (I have not tested or even built the Windows code.)
2017-04-15Specialize Vec::from_elem for other numeric typesMatt Brubeck-0/+39
2017-04-15Specialize Vec::from_elem<u8> to use calloc or memsetMatt Brubeck-3/+32
Fixes #38723.
2017-04-14std::collections docs: Address issues that came up in PR #41286lukaramu-1/+20
* Bound: * Added another example using RangeArgument to illustrate how Bound maps to range endpoints. * Added a note to the existing example that says that it's better to use range syntax in most cases * Added missing /// line * binary_heap::PeakMut: s/Object representing/Structure wrapping * added collections/hash_set/struct.HashSet.html to linkchecker whitelist
2017-04-14refactor: add reason stringEvgeny Safronov-1/+1
2017-04-14fix: add feature to doc testsEvgeny Safronov-0/+1
2017-04-14Add `as_bytes()` for `FromUtf8Error`.Evgeny Safronov-0/+19
This change allows to obtain an underlying invalid UTF-8 bytes without `FromUtf8Error` destruction. Such method may be useful for example in a library that attempts to save both valid and invalid UTF-8 strings in some struct and to be able to provide immutable access to it without destruction.
2017-04-13Various consistency and phrasing fixes in std::collections' docslukaramu-9/+27
* Changed btree_map's and hash_map's Entry (etc.) docs to be consistent * Changed VecDeque's type and module summary sentences to be consistent with each other as well as with other summary sentences in the module * Changed HashMap's and HashSet's summary sentences to be less redundantly phrased and also more consistant with the other summary sentences in the module * Also, added an example to Bound
2017-04-13Various fixes throughout std::collections' docslukaramu-8/+18
* Added links where possible (limited because of facading) * Changed references to methods from `foo()` to `foo` in module docs * Changed references to methods from `HashMap::foo` to just `foo` in top-level docs for `HashMap` and the `default` doc for `DefaultHasher` * Various small other fixes
2017-04-13Update std::collections' docs to use iterator (etc.) boilerplatelukaramu-36/+154
This greatly improves consistency.
2017-04-13Auto merge of #41009 - scottmcm:toowned-clone-into, r=alexcrichtonbors-10/+68
Add a resource-reusing method to `ToOwned` `ToOwned::to_owned` generalizes `Clone::clone`, but `ToOwned` doesn't have an equivalent to `Clone::clone_from`. This PR adds such a method as `clone_into` under a new unstable feature `toowned_clone_into`. Analogous to `clone_from`, this has the obvious default implementation in terms of `to_owned`. I've updated the `libcollections` impls: for `T:Clone` it uses `clone_from`, for `[T]` I moved the code from `Vec::clone_from` and implemented that in terms of this, and for `str` it's a predictable implementation in terms of `[u8]`. Used it in `Cow::clone_from` to reuse resources when both are `Cow::Owned`, and added a test that `Cow<str>` thus keeps capacity in `clone_from` in that situation. The obvious question: is this the right place for the method? - It's here so it lives next to `to_owned`, making the default implementation reasonable, and avoiding another trait. But allowing method syntax forces a name like `clone_into`, rather than something more consistent like `owned_from`. - Another trait would allow `owned_from` and could support multiple owning types per borrow type. But it'd be another single-method trait that generalizes `Clone`, and I don't know how to give it a default impl in terms of `ToOwned::to_owned`, since a blanket would mean overlapping impls problems. I did it this way as it's simpler and many of the `Borrow`s/`AsRef`s don't make sense with `owned_from` anyway (`[T;1]:Borrow<[T]>`, `Arc<T>:Borrow<T>`, `String:AsRef<OsStr>`...). I'd be happy to re-do it the other way, though, if someone has a good solution for the default handling. (I can also update with `CStr`, `OsStr`, and `Path` once a direction is decided.)
2017-04-12Add ToOwned::clone_into (unstable as toowned_clone_into)Scott McMurray-10/+68
to_owned generalizes clone; this generalizes clone_from. Use to_owned to give it a default impl. Customize the impl for [T], str, and T:Clone. Use it in Cow::clone_from to reuse resources when cloning Owned into Owned.
2017-04-12Rollup merge of #41243 - projektir:prim_str_docs, r=GuillaumeGomezTim Neumann-13/+24
Minor nits in primitive str Some minor updates to linking, added some links, doc format, etc. r? @GuillaumeGomez
2017-04-12Minor nits in primitive strprojektir-13/+24
2017-04-11Rollup merge of #40559 - nagisa:manually-drop, r=alexcrichtonCorey Farwell-9/+4
Implement Manually Drop As the RFC has been from approx a week in FCP without any major comments, I’m taking the opportunity to submit the PR early.
2017-04-11Auto merge of #41096 - clarcharr:as_bytes_mut, r=alexcrichtonbors-3/+11
Reduce str transmutes, add mut versions of methods. When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem. I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add `pub(crate)` to these methods for now if the libs team would rather not expose them to the public without an RFC.
2017-04-10Apply clippy's doc_markdown improvements to libcollectionsAndre Bogus-20/+20
Since my last PR led to linker failure, I'm now taking much smaller steps. This only fixes some doc_markdown warnings; as they are in comments only, we shouldn't get any problems building.
2017-04-09Reduce str transmutes, add mut versions of methods.Clar Charr-3/+11
2017-04-09Move away from the ad-hoc NoDrop unionsSimonas Kazlauskas-9/+4
2017-04-06Fix Markdown issues in the docsOliver Middleton-1/+1
* Since the switch to pulldown-cmark reference links need a blank line before the URLs. * Reference link references are not case sensitive. * Doc comments need to be indented uniformly otherwise rustdoc gets confused.
2017-04-05Rollup merge of #41037 - stjepang:move-libxtest, r=alexcrichtonCorey Farwell-2/+6849
Move libXtest into libX/tests This change moves: 1. `libcoretest` into `libcore/tests` 2. `libcollectionstest` into `libcollections/tests` This is a follow-up to #39561. r? @alexcrichton