about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2018-01-21Move Debug for NonNull impl closer to other trait implsSimon Sapin-7/+7
2018-01-21NonNull ended up landing in 1.25Simon Sapin-18/+18
2018-01-20Rollup merge of #47193 - cramertj:result-opts, r=TimNNGuillaume Gomez-0/+58
Add transpose conversions for nested Option and Result These impls are useful when working with combinator methods that expect an option or a result, but you have a `Result<Option<T>, E>` instead of an `Option<Result<T, E>>` or vice versa.
2018-01-20Rename NonNull::empty to dangling.Simon Sapin-1/+2
2018-01-20Preserve formatting options in Debug for NonNull/UniqueSimon Sapin-2/+2
2018-01-20Fix some doc-comment examples for earlier API refactorSimon Sapin-4/+4
https://github.com/rust-lang/rust/pull/41064
2018-01-20Stabilize std::ptr::NonNullSimon Sapin-16/+17
2018-01-20Remove a deprecated (renamed) and unstable method of NonNullSimon Sapin-7/+0
2018-01-20Mark Unique as perma-unstable, with the feature renamed to ptr_internals.Simon Sapin-18/+18
2018-01-20Replace Unique<T> with NonZero<T> in Alloc traitSimon Sapin-0/+7
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-41/+46
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-20Implement Debug for ptr::Shared and ptr::Unique.Corey Farwell-2/+14
Fixes https://github.com/rust-lang/rust/issues/46755.
2018-01-20Spacingoberien-1/+1
2018-01-19Optimize StepBy::nth overflow handlingoberien-2/+6
2018-01-19Adjust language as per suggestionsvarkor-9/+11
2018-01-19Handle Overflowoberien-3/+72
2018-01-19Unit Testsoberien-0/+18
2018-01-19Fix off-by-onesoberien-3/+6
2018-01-19fix doctests for convert::idMazdak-2/+4
2018-01-19add #![feature(convert_id)] to libstd + libcoreMazdak-0/+1
2018-01-19fix prelude reexport of convert::idMazdak-2/+2
2018-01-19add fn core::convert::id<T>(x: T) -> T { x } to the preludeMazdak-0/+3
2018-01-19add fn core::convert::id<T>(x: T) -> T { x }Mazdak-0/+67
2018-01-18Specialize StepBy::nthoberien-0/+12
2018-01-18Make example no_runvarkor-4/+4
2018-01-18Document the behaviour of infinite iterators on potentially-computable methodsvarkor-0/+18
It’s not entirely clear from the current documentation what behaviour calling a method such as `min` on an infinite iterator like `RangeFrom` is. One might expect this to terminate, but in fact, for infinite iterators, `min` is always nonterminating (at least in the standard library). This adds a quick note about this behaviour for clarification.
2018-01-18Rollup merge of #47497 - goffrie:patch-1, r=dtolnaykennytm-7/+4
Remove incorrect `Default::default` links, add a new one `map_or` and `map_or_else` don't use `Default::default`, but `unwrap_or_default` does.
2018-01-18Rollup merge of #47404 - integer32llc:reexport-to-re-export, r=steveklabnikkennytm-5/+5
Standardize on "re-export" rather than "reexport" While working on the book with our editors, it was brought to our attention that we're not consistent with when we use "re-export" versus "reexport". For the book, we've decided (with our editors) to go with "re-export"; in prose, I think that looks better. In code, I'm fine with "reexport". However, the rustdoc generated section is currently "Reexports", so when we have a screenshot of generated documentation with the prose where we use "re-export", it's inconsistent. It's too late to fix this for the book because we're using 1.21.0 for the output in the book, and it's really only one spot so it's not a huge deal, but I'd like to advocate for changing the documentation header so that a future edition of the book can be consistent. The first commit here only changes the documentation section heading text and rustdoc documentation that references it. This is the commit that's most important to me. The second commit changes error messages and associated tests to also be consistent with the use of re-export. This is the next most important commit to me, but I could be argued out of this one because then it won't match code like the `macro_reexports` feature name, which ostensibly should change to `macro_re_exports` to be most consistent but I didn't want to change code. The last commit changes re-export anywhere else in prose: either in documentation comments or regular comments. This is least important as most of them aren't user-visible. Instances like these will likely sneak back in over time. I'm totally fine dropping this commit if anyone wants, but [the hobgoblins made me do it](http://www.bartleby.com/100/420.47.html) and it sets a good example. r? @steveklabnik
2018-01-18Rollup merge of #47333 - arthurprs:iter-position-bounds-check, r=dtolnaykennytm-0/+56
Optimize slice.{r}position result bounds check Second attempt of https://github.com/rust-lang/rust/pull/45501 Fixes https://github.com/rust-lang/rust/issues/45964 Demo: https://godbolt.org/g/N4mBHp
2018-01-16Remove incorrect `Default::default` links, add a new oneGeoffry Song-7/+4
`map_or` and `map_or_else` don't use `Default::default`, but `unwrap_or_default` does.
2018-01-16Adjust wording of Placer trait safety requirementsTaylor Cramer-2/+2
2018-01-15Reexport -> re-export in prose and documentation commentsCarol (Nichols || Goulding)-5/+5
2018-01-15Rollup merge of #47126 - sdroege:exact-chunks, r=blusskennytm-8/+338
Add slice::ExactChunks and ::ExactChunksMut iterators These guarantee that always the requested slice size will be returned and any leftoever elements at the end will be ignored. It allows llvm to get rid of bounds checks in the code using the iterator. This is inspired by the same iterators provided by ndarray. Fixes https://github.com/rust-lang/rust/issues/47115 I'll add unit tests for all this if the general idea and behaviour makes sense for everybody. Also see https://github.com/rust-lang/rust/issues/47115#issuecomment-354715511 for an example what this improves.
2018-01-13Remove `impl Foo for ..` in favor of `auto trait Foo`leonardo.yvens-17/+3
No longer parse it. Remove AutoTrait variant from AST and HIR. Remove backwards compatibility lint. Remove coherence checks, they make no sense for the new syntax. Remove from rustdoc.
2018-01-13Add unit tests for exact_chunks/exact_chunks_mutSebastian Dröge-0/+105
These are basically modified copies of the chunks/chunks_mut tests.
2018-01-13Test the whole chunks instead of just an element in the chunks/chunks_mut testsSebastian Dröge-8/+8
Easy enough to do and ensures that the whole chunk is as expected instead of just the element that was looked at before.
2018-01-13Implement TrustedRandomAccess for slice::{ExactChunks, ExactChunksMut}Sebastian Dröge-0/+18
2018-01-13Remove useless assertionSebastian Dröge-2/+0
2018-01-13Apply review comments from @blussSebastian Dröge-44/+23
- Simplify nth() by making use of the fact that the slice is evenly divisible by the chunk size, and calling next() instead of duplicating it - Call next_back() in last(), they are equivalent - Implement ExactSizeIterator::is_empty()
2018-01-13Add slice::ExactChunks and ::ExactChunksMut iteratorsSebastian Dröge-0/+230
These guarantee that always the requested slice size will be returned and any leftoever elements at the end will be ignored. It allows llvm to get rid of bounds checks in the code using the iterator. This is inspired by the same iterators provided by ndarray. See https://github.com/rust-lang/rust/issues/47115
2018-01-12Optimize slice.{r}position result bounds checkarthurprs-0/+56
2018-01-13Rollup merge of #47365 - Diggsey:issue-42630, r=alexcrichtonkennytm-1/+0
Re-enable num tests on wasm Issue #42630 was closed but the tests are still ignored, supposedly they should pass now.
2018-01-12Derive std::cmp::Reverse as Copy or CloneDan Aloni-1/+1
If the type parameter is Copy or Clone, then `Reverse` should be too.
2018-01-11Enable num tests on wasmDiggory Blake-1/+0
2018-01-11Auto merge of #47180 - varkor:range-iterator-overrides, r=alexcrichtonbors-0/+75
Add iterator method specialisations to Range* Add specialised implementations of `max` for `Range`, and `last`, `min` and `max` for `RangeInclusive`, all of which lead to significant advantages in the generated assembly on x86. Note that adding specialisations of `min` and `last` for `Range` led to no benefit, and adding `sum` for `Range` and `RangeInclusive` led to type inference issues (though this is possibly still worthwhile considering the performance gain). This addresses some of the concerns in #39975.
2018-01-10Add transpose conversions for Option and ResultTaylor Cramer-0/+58
These impls are useful when working with combinator methods that expect an option or a result, but you have a Result<Option<T>, E> instead of an Option<Result<T, E>> or vice versa.
2018-01-09Rollup merge of #46777 - frewsxcv:frewsxcv-rotate, r=alexcrichtonCorey Farwell-5/+33
Deprecate [T]::rotate in favor of [T]::rotate_{left,right}. Background ========== Slices currently have an **unstable** [`rotate`] method which rotates elements in the slice to the _left_ N positions. [Here][tracking] is the tracking issue for this unstable feature. ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate(2); assert_eq!(a, ['c', 'd', 'e', 'f', 'a', 'b']); ``` Proposal ======== Deprecate the [`rotate`] method and introduce `rotate_left` and `rotate_right` methods. ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate_left(2); assert_eq!(a, ['c', 'd', 'e', 'f', 'a', 'b']); ``` ```rust let mut a = ['a', 'b' ,'c', 'd', 'e', 'f']; a.rotate_right(2); assert_eq!(a, ['e', 'f', 'a', 'b', 'c', 'd']); ``` Justification ============= I used this method today for my first time and (probably because I’m a naive westerner who reads LTR) was surprised when the docs mentioned that elements get rotated in a left-ward direction. I was in a situation where I needed to shift elements in a right-ward direction and had to context switch from the main problem I was working on and think how much to rotate left in order to accomplish the right-ward rotation I needed. Ruby’s `Array.rotate` shifts left-ward, Python’s `deque.rotate` shifts right-ward. Both of their implementations allow passing negative numbers to shift in the opposite direction respectively. The current `rotate` implementation takes an unsigned integer argument which doesn't allow the negative number behavior. Introducing `rotate_left` and `rotate_right` would: - remove ambiguity about direction (alleviating need to read docs 😉) - make it easier for people who need to rotate right [`rotate`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rotate [tracking]: https://github.com/rust-lang/rust/issues/41891
2018-01-09Make core::ops::Place an unsafe traitTaylor Cramer-1/+4
2018-01-09Add `min` and `last` specialisations for `Range`varkor-4/+25
2018-01-09Rollup merge of #47272 - GuillaumeGomez:missing-links, r=QuietMisdreavuskennytm-1/+4
Add missing links r? @QuietMisdreavus (please wait for CI, I have a few doubts about the `Write` trait links...)