about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-09-18core: Implement rfold for Map, Cloned, ChainUlrik Sverdrup-0/+33
2017-09-18core: Implement fold / rfold for RevUlrik Sverdrup-0/+12
With both in place, we can cross them over in rev, and we give rfold behaviour to .rev().fold() and so on.
2017-09-18core: Add DoubleEndedIterator::rfoldUlrik Sverdrup-0/+62
rfold is the reverse version of fold. Fold allows iterators to implement a different (non-resumable) internal iteration when it is more efficient than the external iteration implemented through the next method. (Common examples are VecDeque and .chain()). Introduce rfold() so that the same customization is available for reverse iteration. This is achieved by both adding the method, and by having the Rev<I> adaptor connect Rev::rfold -> I::fold, Rev::fold -> I::rfold.
2017-09-18core: Small fix in fold docsUlrik Sverdrup-1/+1
Adaptors are things that take iterators and adapt them into other iterators. With this definition, fold is just a usual method, because it doesn't normally make an iterator.
2017-09-18Rollup merge of #44668 - iwillspeak:into-iterator-docs, r=steveklabnikAlex Crichton-0/+17
Add Example of `IntoIterator` as Trait Bound to Docs Part of #44600.
2017-09-18Rollup merge of #44657 - Ixrec:patch-1, r=eddybAlex Crichton-4/+4
Replace str's transmute() calls with pointer casts After the following conversation in #rust-lang: ``` [14:43:50] <Ixrec> TIL the implementation of from_utf_unchecked is literally just "mem::transmute(x)" [14:43:59] <Ixrec> no wonder people keep saying transmute is overpowered [15:15:30] <eddyb> Ixrec: it should be a pointer cast lol [15:15:46] <eddyb> unless it doesn't let you [16:50:34] <Ixrec> https://play.rust-lang.org/?gist=d1e6b629ad9ec1baf64ce261c63845e6&version=stable seems like it does let me [16:52:35] <eddyb> Ixrec: yeah that's the preferred impl [16:52:46] <eddyb> Ixrec: it just wasn't in 1.0 [16:52:50] <eddyb> IIRC [16:53:00] <eddyb> (something something fat pointers) ``` Since I already wrote half of the preferred impls in the playground, might as well make an actual PR.
2017-09-18Add Example of `IntoIterator` as Trait Bound to DocsWill Speak-0/+17
Part of #44600.
2017-09-17Add `<*const T>::align_offset` and use it in `memchr`Oliver Schneider-35/+76
2017-09-17missed a 'mut'Ixrec-1/+1
2017-09-17Remove unused str_eq lang itemleonardo.yvens-3/+0
It's not a lang item anymore. Also remove outdated note.
2017-09-17Replace str's transmute() calls with pointer castsIxrec-4/+4
After the following conversation in #rust-lang: ``` [14:43:50] <Ixrec> TIL the implementation of from_utf_unchecked is literally just "mem::transmute(x)" [14:43:59] <Ixrec> no wonder people keep saying transmute is overpowered [15:15:30] <eddyb> Ixrec: it should be a pointer cast lol [15:15:46] <eddyb> unless it doesn't let you [16:50:34] <Ixrec> https://play.rust-lang.org/?gist=d1e6b629ad9ec1baf64ce261c63845e6&version=stable seems like it does let me [16:52:35] <eddyb> Ixrec: yeah that's the preferred impl [16:52:46] <eddyb> Ixrec: it just wasn't in 1.0 [16:52:50] <eddyb> IIRC [16:53:00] <eddyb> (something something fat pointers) ``` Since I already wrote half of the preferred impls in the playground, might as well make an actual PR.
2017-09-17Rollup merge of #44639 - budziq:stabilize_needs_drop, r=dtolnayTim Neumann-2/+1
stabilized needs_drop (fixes #41890) fixes #41890
2017-09-17Rollup merge of #44595 - budziq:stabilize_compiler_fences, r=alexcrichtonTim Neumann-5/+54
stabilized compiler_fences (fixes #41091) I did not know what to proceed with "unstable-book" entry. The feature would no longer be unstable so I have deleted it. If it was the wrong call I'll revert it (unfortunately his case is not described in the CONTRIBUTING.md).
2017-09-17Rollup merge of #44567 - budziq:stabilize_iterator_for_each, r=alexcrichtonTim Neumann-5/+1
stabilized iterator_for_each (closes #42986) Also updated clippy and rls as these use the iterator_for_each I've made my first PR's today so most likely I've done something wrong. Sorry about that!
2017-09-17Auto merge of #44634 - alexcrichton:rollup, r=alexcrichtonbors-7/+66
Rollup of 19 pull requests - Successful merges: #44273, #44356, #44395, #44531, #44537, #44542, #44560, #44567, #44574, #44577, #44586, #44589, #44590, #44593, #44598, #44606, #44609, #44616, #44631 - Failed merges:
2017-09-16Rollup merge of #44593 - budziq:stabilize_ord_max_min, r=alexcrichtonAlex Crichton-7/+2
stabilized ord_max_min (fixes #25663)
2017-09-16Rollup merge of #44577 - cuviper:flat_map-fold, r=alexcrichtonAlex Crichton-0/+64
Customize `<FlatMap as Iterator>::fold` `FlatMap` can use internal iteration for its `fold`, which shows a performance advantage in the new benchmarks: test iter::bench_flat_map_chain_ref_sum ... bench: 4,354,111 ns/iter (+/- 108,871) test iter::bench_flat_map_chain_sum ... bench: 468,167 ns/iter (+/- 2,274) test iter::bench_flat_map_ref_sum ... bench: 449,616 ns/iter (+/- 6,257) test iter::bench_flat_map_sum ... bench: 348,010 ns/iter (+/- 1,227) ... where the "ref" benches are using `by_ref()` that isn't optimized. So this change shows a decent advantage on its own, but much more when combined with a `chain` iterator that also optimizes `fold`.
2017-09-16Auto merge of #43989 - circuitfox:sliceext-binary-search-sig, r=alexcrichtonbors-15/+10
Remove Borrow bound from SliceExt::binary_search #37761 added a Borrow bound to `binary_search` and `binary_search_by_key` in `core::SliceExt`, but did not add it to the methods in `std::slice`. #41590 attempted to add this bound to `std::slice` but was not merged due to breakage. This PR removes the bound in `core::SliceExt`, so that these methods will have the same signature in `core` and `std`. Fixes #41561
2017-09-16stabilized needs_drop (fixes #41890)Michal Budzynski-2/+1
2017-09-16stabilized iterator_for_each (closes #42986)Michal Budzynski-5/+1
updated clippy and rls as it uses the iterator_for_each
2017-09-16Added more text from unstable-book to `compiler_fence` docsMichal Budzynski-4/+19
2017-09-16Added example to `compiler_fence` docs taken from unstable-bookMichal Budzynski-0/+34
2017-09-16stabilized compiler_fences (fixes #41091)Michal Budzynski-1/+1
2017-09-16Auto merge of #43964 - Gankro:unsafe-reform, r=sfacklerbors-12/+1174
implement unsafe pointer methods I also cleaned up some existing documentation a bit here or there since I was doing so much auditing of it. Most notably I significantly rewrote the `offset` docs to clarify safety (`*const` and `*mut`'s offset docs had actually diverged).
2017-09-16Auto merge of #43017 - durka:stabilize-const-invocation, r=eddybbors-2/+55
Individualize feature gates for const fn invocation This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward. This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review. - `std::cell` - `Cell::new` - `RefCell::new` - `UnsafeCell::new` - `std::mem` - `size_of` - `align_of` - `std::ptr` - `null` - `null_mut` - `std::sync` - `atomic` - `Atomic{Bool,Ptr,Isize,Usize}::new` - `once` - `Once::new` - primitives - `{integer}::min_value` - `{integer}::max_value` Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time. After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR. - `std::sync` - `atomic` - `ATOMIC_{BOOL,ISIZE,USIZE}_INIT` - `once` - `ONCE_INIT`
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-2/+55
2017-09-15Add a specific test for `FlatMap::fold`Josh Stone-0/+16
2017-09-15stabilized ord_max_min (fixes #25663)Michal Budzynski-7/+2
2017-09-14Rollup merge of #44552 - durka:patch-42, r=alexcrichtonCorey Farwell-8/+8
update "since" for discriminant_value It's [going](https://github.com/rust-lang/rust/pull/44263#issuecomment-329257597) to be backported to beta. r? @alexcrichton
2017-09-14Rollup merge of #44536 - Havvy:transmute-docs, r=steveklabnikCorey Farwell-3/+3
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-14Rollup merge of #44477 - napen123:master, r=frewsxcvCorey Farwell-0/+13
Add doc examples to str::from_utf8_unchecked_mut Fixes #44461
2017-09-14Rollup merge of #44472 - smt923:master, r=frewsxcvCorey Farwell-0/+31
Add short doc examples for str::from_utf8_mut Fixes #44462
2017-09-14Customize `<FlatMap as Iterator>::fold`Josh Stone-0/+48
`FlatMap` can use internal iteration for its `fold`, which shows a performance advantage in the new benchmarks: test iter::bench_flat_map_chain_ref_sum ... bench: 4,354,111 ns/iter (+/- 108,871) test iter::bench_flat_map_chain_sum ... bench: 468,167 ns/iter (+/- 2,274) test iter::bench_flat_map_ref_sum ... bench: 449,616 ns/iter (+/- 6,257) test iter::bench_flat_map_sum ... bench: 348,010 ns/iter (+/- 1,227) ... where the "ref" benches are using `by_ref()` that isn't optimized. So this change shows a decent advantage on its own, but much more when combined with a `chain` iterator that also optimizes `fold`.
2017-09-13update "since" for discriminant_valueAlex Burka-8/+8
It's going to be backported to beta.
2017-09-13Fix example in transmute; add safety requirement to Vec::from_raw_partsHavvy-3/+3
2017-09-12Remove Invalid UTF-8 from str::from_utf8_unchecked_mutEthan Dagner-15/+0
2017-09-12Auto merge of #44015 - kennytm:hasher, r=alexcrichtonbors-0/+59
impl Hasher for {&mut Hasher, Box<Hasher>} **Rationale:** The `Hash` trait has `fn hash<H: Hasher>(&self, state: &mut H)`, which can only accept a `Sized` hasher, even if the `Hasher` trait is object-safe. We cannot retroactively add the `?Sized` bound without breaking stability, thus implementing `Hasher` to a trait object reference is the next best solution. **Warning:** These `impl` are insta-stable, and should need an FCP. I don't think a full RFC is necessary.
2017-09-12Disable the new Hasher tests on Emscripten.kennytm-0/+3
2017-09-12impl Hasher for {&mut Hasher, Box<Hasher>}kennytm-0/+56
2017-09-12Auto merge of #44310 - ldr709:master, r=BurntSushibors-2/+73
Additional traits for std::mem::ManuallyDrop The first commit adds `Clone` and `Copy` trait implementations for `ManuallyDrop`. Although `Drop` and `Copy` cannot be used together, this may be useful for generics. The second commit adds implementations common traits. I do not think this is necessary, as they could be implemented in a wrapper type outside the standard library, but it would make `ManuallyDrop` more convenient to use.
2017-09-10implement unsafe pointer methodsAlexis Beingessner-12/+1174
2017-09-10Add doc examples to str::from_utf8_unchecked_mutEthan Dagner-0/+28
Fixes #44461
2017-09-10Actually fix the trailing whitespacesmt923-1/+1
2017-09-10Fix markdown link for Utf8Errorsmt923-1/+3
2017-09-10Fix trailing whitespacesmt923-1/+0
2017-09-10Use rvalue promotion to 'static instead of static items.Eduard-Mihai Burtescu-10/+3
2017-09-10Fix incorrect markdown titlesmt923-1/+1
2017-09-10Added short examples for 'str::from_utf8_mut'smt923-0/+30
2017-09-09Auto merge of #44438 - Xaeroxe:clamp, r=Mark-Simulacrumbors-24/+0
Revert clamp Revert clamp per https://github.com/rust-lang/rust/issues/44095#issuecomment-328218316 while we take time to assess the potential backwards compatibility damage done by it.
2017-09-08Revert "Add clamp functions"Jacob Kiesel-26/+0
This reverts commit c589f867f89d4e6e48c6602aed8e878208d4822f.