summary refs log tree commit diff
path: root/src/liballoc/vec.rs
AgeCommit message (Collapse)AuthorLines
2018-03-30Rollup merge of #49466 - glandium:master, r=rkruppekennytm-2/+2
Use f{32,64}::to_bits for is_zero test in vec::SpecFromElem vec::SpecFromElem provides an optimization to use calloc to fill a Vec when the element given to fill the Vec is represented by 0. For floats, the test for that currently used is `x == 0. && x.is_sign_positive()`. When compiled in a standalone function, rustc generates the following assembly: ``` xorps xmm1, xmm1 ucomisd xmm0, xmm1 setnp al sete cl and cl, al movq rax, xmm0 test rax, rax setns al and al, cl ret ``` A simpler test telling us whether the value is represented by 0, is `x.to_bits() == 0`, which rustc compiles to: ``` movq rax, xmm0 test rax, rax sete al ret ``` Not that the test is hot in any way, but it also makes it clearer what the intent in the rust code is.
2018-03-29Move RangeArguments to {core::std}::ops and rename to RangeBoundsSimon Sapin-4/+3
These unstable items are deprecated: * The `std::collections::range::RangeArgument` reexport * The `std::collections::range` module.
2018-03-29Move alloc::Bound to {core,std}::opsSimon Sapin-1/+1
The stable reexport `std::collections::Bound` is now deprecated. Another deprecated reexport could be added in `alloc`, but that crate is unstable.
2018-03-29Use f{32,64}::to_bits for is_zero test in vec::SpecFromElemMike Hommey-2/+2
vec::SpecFromElem provides an optimization to use calloc to fill a Vec when the element given to fill the Vec is represented by 0. For floats, the test for that currently used is `x == 0. && x.is_sign_positive()`. When compiled in a standalone function, rustc generates the following assembly: ``` xorps xmm1, xmm1 ucomisd xmm0, xmm1 setnp al sete cl and cl, al movq rax, xmm0 test rax, rax setns al and al, cl ret ``` A simpler test telling us whether the value is represented by 0, is `x.to_bits() == 0`, which rustc compiles to: ``` movq rax, xmm0 test rax, rax sete al ret ``` Not that the test is hot in any way, but it also makes it clearer what the intent in the rust code is.
2018-03-28Rollup merge of #49452 - frewsxcv:frewsxcv-vec-cap-len, r=dtolnaykennytm-3/+4
Clarify "length" wording in `Vec::with_capacity`. Fixes https://github.com/rust-lang/rust/issues/49448.
2018-03-28Clarify "length" wording in `Vec::with_capacity`.Corey Farwell-3/+4
2018-03-27Implement `shrink_to` method on collectionsDiggory Blake-1/+26
2018-03-14implementing fallible allocation API (try_reserve) for Vec, String and HashMapsnf-0/+78
2018-03-09Add missing urlsGuillaume Gomez-7/+14
2018-03-06Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichtonkennytm-2/+2
Stabilize FusedIterator FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate. Closes #35602
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-2/+2
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-2/+2
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-03-02Don't have Vec<T> delegate to [T]'s bounds for indexingJonathan Behrens-7/+11
2018-03-02Update commentsJonathan Behrens-2/+2
2018-03-02Have Vec use slice's implementations of Index<I> and IndexMut<I>Jonathan Behrens-125/+5
2018-02-22[docs] Minor wording changes to drain_filter docsMatt Brubeck-2/+2
The docs currently say, "If the closure returns false, it will try again, and call the closure on the next element." But this happens regardless of whether the closure returns true or false.
2018-02-16Clarify contiguity of Vec's elements.Sergio Benitez-5/+5
2018-02-13Switch to retain calling drain_filter.Jacob Kiesel-21/+1
2018-02-08Swap `ptr::read` for `ptr::drop_in_place`Jacob Kiesel-1/+1
2018-02-07Apply optimization from #44355 to retainJacob Kiesel-4/+9
2018-01-24Auto merge of #47299 - cramertj:unsafe-placer, r=alexcrichtonbors-1/+1
Make core::ops::Place an unsafe trait Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-5/+5
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-09Make core::ops::Place an unsafe traitTaylor Cramer-1/+1
2018-01-01Fix panic condition docs for Vec::insert.Corey Farwell-1/+1
Fixes https://github.com/rust-lang/rust/issues/47065.
2017-12-20Clarify vec docs on deallocation (fixes #46879)Manish Goregaokar-2/+4
2017-12-16Move PhantomData<T> from Shared<T> to users of both Shared and #[may_dangle]Simon Sapin-0/+3
After discussing [1] today with @pnkfelix and @Gankro, we concluded that it’s ok for drop checking not to be much smarter than the current `#[may_dangle]` design which requires an explicit unsafe opt-in. [1] https://github.com/rust-lang/rust/issues/27730#issuecomment-316432083
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+1
2017-11-21fix some typosMartin Lindhe-1/+1
2017-11-03Remove unused AsciiExt imports and fix tests related to ascii methodsLukas Kalbertodt-2/+0
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
2017-10-09usize index message for vecGuillaume Gomez-1/+24
2017-10-01Resolves #36284 - vec.rs documentationSean Prashad-5/+1
2017-09-24Backport libs stabilizations to 1.21 betaDavid Tolnay-6/+6
This includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640
2017-09-20Auto merge of #44355 - Xaeroxe:optimize_drain_filter, r=alexcrichtonbors-1/+7
Optimize drain_filter This PR cuts out two copies from each iteration of `drain_filter` by exchanging the swap operation for a copy_nonoverlapping function call instead. Since the data being swapped is not needed anymore we can just overwrite it instead.
2017-09-18Add requested commentJacob Kiesel-0/+3
2017-09-17stabilized vec_splice (fixes #32310)Michal Budzynski-7/+6
2017-09-14Rollup merge of #44536 - Havvy:transmute-docs, r=steveklabnikCorey Farwell-0/+1
Fix example in transmute; add safety requirement to Vec::from_raw_parts This fixes the second bullet point on #44281 and also removes some incorrect information.
2017-09-13Fix example in transmute; add safety requirement to Vec::from_raw_partsHavvy-0/+1
2017-09-12Fix drain_filter doctest.David Adler-3/+6
2017-09-11Try using ref to raw conversionJacob Kiesel-2/+2
2017-09-05Fix ownership issuesJacob Kiesel-1/+3
2017-09-05Remove unneeded copyJacob Kiesel-1/+2
2017-08-16Auto merge of #43710 - zackmdavis:field_init_shorthand_power_slam, ↵bors-2/+2
r=Mark-Simulacrum use field init shorthand EVERYWHERE Like #43008 (f668999), but [(lacking reasons to be more timid)](https://github.com/rust-lang/rust/pull/43008#issuecomment-312463564) _much more aggressive_. r? @Mark-Simulacrum
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-2/+2
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Auto merge of #43245 - Gankro:drain-filter, r=sfacklerbors-0/+113
Add Vec::drain_filter This implements the API proposed in #43244. So I spent like half a day figuring out how to implement this in some awesome super-optimized unsafe way, which had me very confident this was worth putting into the stdlib. Then I looked at the impl for `retain`, and was like "oh dang". I compared the two and they basically ended up being the same speed. And the `retain` impl probably translates to DoubleEndedIter a lot more cleanly if we ever want that. So now I'm not totally confident this needs to go in the stdlib, but I've got two implementations and an amazingly robust test suite, so I figured I might as well toss it over the fence for discussion.
2017-08-12Fix some typosBastien Orivel-1/+1
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-1/+1
2017-07-26Rollup merge of #43455 - QuietMisdreavus:extend-spec-docs, r=steveklabnikMark Simulacrum-0/+6
add a note to Vec's Extend<&T> impl about its slice specialization From the regular documentation view, it's not at all apparent that [this specialization](https://github.com/rust-lang/rust/blob/5669c9988f50788b5ab5dee2d4538519d4e5663d/src/liballoc/vec.rs#L1879-L1891) exists for `slice::Iter`. This adds a documentation blurb to the Extend impl itself to note that this optimization exists.
2017-07-25add a note to Vec's Extend<&T> impl about its slice specializationQuietMisdreavus-0/+6
2017-07-22Add conversions from references to NonZero pointers, Unique, and SharedSimon Sapin-1/+1
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-2/+2