Commit graph

135 commits

Author SHA1 Message Date
Richard Wiedenhöft
07e8d84479 Add const_unchecked_layout test to libcore/tests 2019-05-14 09:41:50 +02:00
Mazdak Farrokhzad
c8ef512480
Rollup merge of #60201 - RalfJung:core-tests, r=alexcrichton
coretest: Downgrade deny to warn

The `deny` causes a build failure in https://github.com/RalfJung/miri-test-libstd. Since we use `-D warnings` for rustc builds, `warn` should be enough to lead to compile errors here, without impeding external builds.
2019-05-13 21:36:51 +02:00
Mazdak Farrokhzad
b71f8d4e1b Stabilize Iterator::copied in 1.36.0. 2019-04-27 16:45:30 +02:00
Christopher Serr
cf9d6672b7 Remove feature gates from std and tests 2019-04-26 12:33:42 +02:00
Tobias Rapp
c7d47c8cf4 Add tests for saturating_abs() and saturating_neg functions 2019-04-25 17:04:17 +02:00
Ralf Jung
4cb6d1c523 deny -> warn 2019-04-23 17:51:10 +02:00
Philipp Hansch
c9ae68812f
Deny rust_2018_idioms in libcore tests 2019-04-20 18:44:29 +02:00
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
Mazdak Farrokhzad
2f37c5a358
Rollup merge of #55448 - Mokosha:SortAtIndex, r=bluss
Add 'partition_at_index/_by/_by_key' for slices.

This is an analog to C++'s std::nth_element (a.k.a. quickselect).

Corresponds to tracking bug #55300.
2019-04-03 04:36:09 +02:00
Jean-Marie Comets
70fa616a23 Stabilize refcell_replace_swap feature, closes #43570 2019-03-31 10:54:14 +02:00
Mazdak Farrokhzad
f90ac4f04a
Rollup merge of #58717 - hellow554:nonzero_parse, r=oli-obk
Add FromStr impl for NonZero types

This is a WIP implementation because I do have some questions regarding the solution.

Somebody should ping the lang team on this I guess.
Please see the annotations on the code for more details.

Closes #58604
2019-03-28 13:35:29 +01:00
Joshua Liebow-Feeser
de4be2cd85 Stabilize refcell_map_split feature
- Closes #51476
2019-03-18 15:06:34 -07:00
Aleksey Kladov
08f264d576 Stabilize Option::copied
closes https://github.com/rust-lang/rust/issues/57126
2019-03-16 14:11:23 +03:00
Pavel Krajcevski
3f306db3db Add initial implementation of 'sort_at_index' for slices -- analog to C++'s std::nth_element (a.k.a. quickselect)
Add some more notes to the documentation:

- Mention that the median can be found if we used `len() / 2`.
- Mention that this function is usually called "kth element" in other libraries.

Address some comments in PR:

- Change wording on some of the documentation
- Change recursive function into a loop

Update name to `partition_at_index` and add convenience return values.

Address reviewer comments:

- Don't swap on each iteration when searching for min/max element.
- Add some docs about when we panic.
- Test that the sum of the lengths of the output matches the length of the input.
- Style fix for for-loop.

Address more reviewer comments

Fix Rng stuff for test

Fix doc test build

Don't run the partition_at_index test on wasm targets

Miri does not support entropy for test partition_at_index
2019-03-11 10:31:21 -07:00
Marcel Hellwig
ad240ea70c add feature flag to test 2019-02-28 14:47:32 +01:00
bors
00aae71f50 Auto merge of #58302 - SimonSapin:tryfrom, r=alexcrichton
Stabilize TryFrom and TryInto with a convert::Infallible empty enum

This is the plan proposed in https://github.com/rust-lang/rust/issues/33417#issuecomment-423073898
2019-02-25 20:24:10 +00:00
Simon Sapin
3906cb9187 Stabilize iter::from_fn
FCP: https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234
2019-02-19 14:10:07 +01:00
Simon Sapin
c80a8f51dc Stabilize TryFrom and TryInto 2019-02-13 18:00:18 +01:00
Kevin Leimkuhler
8dea0d0172 Add initial impl of is_sorted to Iterator 2019-01-17 22:34:42 -08:00
Stjepan Glavina
04c74f46f0 Add core::iter::once_with 2019-01-13 16:58:08 +01:00
bors
a7be40c65a Auto merge of #56534 - xfix:copied, r=@SimonSapin
Add unstable Iterator::copied()

Initially suggested at https://github.com/bluss/rust-itertools/pull/289, however the maintainers of itertools suggested this may be better of in a standard library.

The intent of `copied` is to avoid accidentally cloning iterator elements after doing a code refactoring which causes a structure to be no longer `Copy`. This is a relatively common pattern, as it can be seen by calling `rg --pcre2 '[.]map[(][|](?:(\w+)[|] [*]\1|&(\w+)[|] \2)[)]'` on Rust main repository. Additionally, many uses of `cloned` actually want to simply `Copy`, and changing something to be no longer copyable may introduce unnoticeable performance penalty.

Also, this makes sense because the standard library includes `[T].copy_from_slice` to pair with `[T].clone_from_slice`.

This also adds `Option::copied`, because it makes sense to pair it with `Iterator::copied`. I don't think this feature is particularly important, but it makes sense to update `Option` along with `Iterator` for consistency.
2018-12-26 19:39:19 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Konrad Borowski
8ac5380ea0
Merge branch 'master' into copied 2018-12-23 16:47:11 +01:00
Clar Fon
fb18ddaaaa Add DoubleEndedIterator::nth_back 2018-12-20 01:18:04 -05:00
Konrad Borowski
fe45e9a886 Add tests for Iterator::copied() 2018-12-05 15:40:15 +01:00
Konrad Borowski
fcc46040a9 Add tests for Option::copied() 2018-12-05 15:40:14 +01:00
Simon Sapin
641c4909e4 Add std::iter::successors 2018-11-20 18:22:40 +01:00
Alex Crichton
d0060d72e5 Bump nightly to 1.32.0
* Also update the bootstrap compiler
* Update cargo to 1.32.0
* Clean out stage0 annotations
2018-10-31 11:53:50 -07:00
Scott McMurray
37393576ec Stabilize impl_header_lifetime_elision in 2015
It's already stable in 2018; this finishes the stabilization.
2018-10-19 21:57:52 -07:00
Sebastian Dröge
52cc6fde4b Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()
Fixes #55177
2018-10-18 18:51:56 +03:00
Sebastian Dröge
b08ca2958e Stabilize slice::chunks_exact() and slice::chunks_exact_mut()
Fixes #47115
2018-10-18 18:51:56 +03:00
Sebastian Dröge
80a8e5c1f7 Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()
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-18 10:38:05 +03:00
Clément Renault
8c01c225ce Stabilize the Option::replace method 2018-10-08 10:06:45 +02:00
Scott McMurray
d4840da779 Activate the feature in the libcore tests too 2018-09-29 23:29:58 -07:00
Pietro Albini
6a0f45b3f4
Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichton
Rename slice::exact_chunks() to slice::chunks_exact()

See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815
and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-25 22:34:47 +02:00
Sebastian Dröge
e09e45041b Rename slice::exact_chunks() to slice::chunks_exact()
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815
and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-24 22:43:06 +03:00
Clément Renault
78bccb3540 Introduce the partition_dedup/by/by_key methods for slices 2018-09-23 09:09:54 +02:00
Jack O'Connor
d0e59f563d add tests for copy_within 2018-09-20 02:35:32 -04:00
Ralf Jung
f4f114002e stabilize slice_align_to 2018-08-28 10:41:53 +02:00
Aleksey Kladov
057878ac71 Stablize Iterator::find_map 2018-08-15 18:44:44 +03:00
varkor
c157ec87ed Fix 2018 edition tests 2018-08-05 15:54:49 +01:00
varkor
319b052357 Fix stage 2 tests 2018-08-05 15:54:49 +01:00
varkor
64185f205d Remove unnecessary or invalid feature attributes 2018-08-05 15:54:48 +01:00
Brad Gibson
56016cb1e0 resolved upstream merge conflicts 2018-07-29 22:13:12 -07:00
Ralf Jung
5feedbd9f8 add smoke test for ManuallyDrop 2018-07-27 12:22:26 +02:00
Clément RENAULT
af87a3594a
Add a basic test to Option::replace 2018-07-09 14:50:54 +02:00
Pietro Albini
0f8343830b
Rollup merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=SimonSapin
Stabilize Iterator::flatten in 1.29, fixes #48213.

This PR stabilizes [`Iterator::flatten`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.flatten) in *version 1.29* (1.28 goes to beta in 10 days, I don't think there's enough time to land it in that time, but let's see...).

Tracking issue is:  #48213.

cc @bluss re. itertools.
r? @SimonSapin
ping @pietroalbini -- let's do a crater run when this passes CI :)
2018-07-01 21:18:43 +02:00
bors
aec00f97e1 Auto merge of #51466 - joshlf:ref-split, r=dtolnay
Add Ref/RefMut map_split method

As proposed [here](https://internals.rust-lang.org/t/make-refcell-support-slice-splitting/7707).

TLDR: Add a `map_split` method that allows multiple `RefMut`s to exist simultaneously so long as they refer to non-overlapping regions of the original `RefCell`. This is useful for things like the slice `split_at_mut` method.
2018-06-17 07:49:25 +00:00
Joshua Liebow-Feeser
2a999b4b52 Add Ref/RefMut map_split method 2018-06-13 11:35:39 -07:00
Mazdak Farrokhzad
85796dd0ba stabilize Iterator::flatten in 1.29, fixes #48115. 2018-06-11 23:10:51 +02:00