Commit graph

415 commits

Author SHA1 Message Date
Mazdak Farrokhzad
a1ff450a68
Rollup merge of #61398 - kennytm:stabilize-copy-within, r=SimonSapin
Stabilize copy_within

Closes #54236.
2019-06-13 01:49:26 +02:00
Mazdak Farrokhzad
3a8dc44f3c
Rollup merge of #61671 - koalatux:nth-back-range, r=KodrAus
implement nth_back for Range(Inclusive)

This is part of  #54054.
2019-06-12 04:22:51 +02:00
Adrian Friedli
8590074a01
implement nth_back for RangeInclusive 2019-06-09 22:45:11 +02:00
Ralf Jung
60d8675312 Miri: disable a slow test 2019-06-09 14:04:30 +02:00
Adrian Friedli
26d4c8f01c
implement nth_back for Range 2019-06-08 22:30:45 +02:00
Mazdak Farrokhzad
654854fdb5
Rollup merge of #61376 - czipperz:bound-cloned, r=sfackler
Add Bound::cloned()

Suggested by #61356
2019-06-06 22:39:09 +02:00
kennytm
427f1a49f6
Update src/libcore/tests/slice.rs
Co-Authored-By: Jack O'Connor <oconnor663@gmail.com>
2019-06-04 00:27:28 +08:00
kennytm
aac9bc5ffa
copy_within: replace element access by pointer arithmetic to avoid UB
This ensures we won't accidentally read *src or *dest even when count = 0.
2019-06-02 23:30:18 +08:00
Chris Gregory
c478efbe6a Enable feature bound_cloned for tests 2019-06-01 22:39:13 -07:00
Mazdak Farrokhzad
7d3a0dd2fb
Rollup merge of #61364 - lzutao:stabilize-reverse_bits, r=Centril
Stabilize reverse_bits feature

FCP done in https://github.com/rust-lang/rust/issues/48763#issuecomment-497349379

Closes #48763

r? @Centril
2019-06-01 06:50:03 +02:00
Chris Gregory
a21a0e0268 Import Bound in tests 2019-05-31 16:56:26 -05:00
Chris Gregory
df845784ee Add Bound tests 2019-05-31 11:36:37 -05:00
kennytm
be6fc6aca2
Stabilize copy_within 2019-05-31 20:02:07 +08:00
Lzu Tao
1c26bbf628 Stabilize reverse_bits feature 2019-05-31 04:43:53 +00:00
Lzu Tao
0c35c699d4 Stabilize iter_nth_back feature 2019-05-30 18:00:17 +00:00
Mazdak Farrokhzad
f0ea975a1c
Rollup merge of #61048 - wizAmit:feature/nth_back_chunks, r=scottmcm
Feature/nth back chunks

A succinct implementation for nth_back on chunks. Thank you @timvermeulen for the guidance.

r? @timvermeulen
2019-05-29 08:15:55 +02:00
Mazdak Farrokhzad
23b9b8320b
Rollup merge of #60555 - timvermeulen:rchunks_nth_back, r=scottmcm
Implement nth_back for RChunks(Exact)(Mut)

Part of #54054.

These implementations may not be optimal because of the use of `self.len()`, but it's quite cheap and simplifies the code a lot.

There's quite some duplication going on here, I wouldn't mind cleaning this up later. A good next step would probably be to add private `split_off_up_to`/`split_off_from` helper methods for slices since their behavior is commonly useful throughout the `Chunks` types.

r? @scottmcm
2019-05-29 08:15:51 +02:00
Mazdak Farrokhzad
d67d1f24dc
Rollup merge of #58975 - jtdowney:iter_arith_traits_option, r=dtolnay
Implement `iter::Sum` and `iter::Product` for `Option`

This is similar to the existing implementation for `Result`. It will take each item into the accumulator unless a `None` is returned.

I based a lot of this on #38580. From that discussion it didn't seem like this addition would be too controversial or difficult. One thing I still don't understand is picking the values for the `stable` attribute. This is my first non-documentation PR for rust so I am open to any feedback on improvements.
2019-05-29 08:15:48 +02:00
wizAmit
bcfd1f39e7 fix merge conflicts 2019-05-22 22:55:16 +05:30
wizAmit
9309447397 succint implementation 2019-05-22 22:27:30 +05:30
@amit.chandra
29a103daa9 wip nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22 22:02:17 +05:30
@amit.chandra
2080b86566 hopefully working nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22 21:58:57 +05:30
@amit.chandra
dc82626262 wip nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-22 21:58:57 +05:30
wizAmit
16223e4bea new implementation for nth_back for chunks 2019-05-14 13:28:43 +05:30
Richard Wiedenhöft
07e8d84479 Add const_unchecked_layout test to libcore/tests 2019-05-14 09:41:50 +02:00
@amit.chandra
aff83c80dd hopefully working nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14 12:26:25 +05:30
@amit.chandra
02a148dba2 wip nth_back on chunks
Signed-off-by: wizAmit <amitforfriends_dns@yahoo.com>
2019-05-14 12:26:25 +05:30
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
Tim Vermeulen
5eb0e08d0f Implement nth_back for RChunks(Exact)(Mut) 2019-05-05 11:21:30 +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
bors
c32171bd5e Auto merge of #60192 - t-rapp:tr-saturating-funcs, r=alexcrichton
Implement saturating_abs() and saturating_neg() functions for signed integer types

Similar to wrapping_abs() / wrapping_neg() functions but saturating at the numeric bounds instead of wrapping around. Complements the existing set of functions with saturation mechanics.

cc #59983
2019-04-25 17:26:20 +00: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
varkor
7f0f0e31ec Remove double trailing newlines 2019-04-22 16:57:01 +01:00
Philipp Hansch
c9ae68812f
Deny rust_2018_idioms in libcore tests 2019-04-20 18:44:29 +02:00
Mazdak Farrokhzad
291e44b381
Rollup merge of #60023 - koalatux:nth-back, r=scottmcm
implement specialized nth_back() for Bytes, Fuse and Enumerate

Hi,

After my first PR has been successfully merged, here is my second pull request :-)

Also this PR contains some specializations for the problem discussed in #54054.
2019-04-19 06:03:12 +02:00
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
Ralf Jung
d55e4b7a25 test sort_unstable in Miri 2019-04-17 09:47:36 +02:00
Adrian Friedli
2605537012
implement nth_back for Enumerate 2019-04-16 23:45:59 +02:00
Ralf Jung
9b21324db2 Miri now supports entropy, but is still slow 2019-04-16 20:04:17 +02:00
David Tolnay
cfd31fb4df
Include trailing comma in multiline Debug representation
This commit changes the behavior of Formatter::debug_struct,
debug_tuple, debug_list, debug_set, and debug_map to render trailing
commas in {:#?} mode, which is the dominant style in modern Rust code.

Before:

    Language {
        name: "Rust",
        trailing_commas: false
    }

After:

    Language {
        name: "Rust",
        trailing_commas: true,
    }
2019-04-05 06:45:40 -07: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
Mazdak Farrokhzad
5e8998a98d
Rollup merge of #59444 - cuviper:steps_between, r=scottmcm
Implement useful steps_between for all integers

We can use `usize::try_from` to convert steps from any size of integer.
This enables a meaningful `size_hint()` for larger ranges, rather than
always just `(0, None)`. Now they return the true `(len, Some(len))`
when it fits, otherwise `(usize::MAX, None)` for overflow.
2019-04-02 13:47:24 +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
Josh Stone
413aaf3227
Rollup merge of #59393 - czipperz:refactor_tuple_comparison_tests, r=shepmaster
Refactor tuple comparison tests
2019-03-27 18:15:32 -07:00
Josh Stone
3d389f244a Test the size_hint of empty ranges too 2019-03-26 10:39:03 -07:00
Josh Stone
01162d86c5 Implement useful steps_between for all integers
We can use `usize::try_from` to convert steps from any size of integer.
This enables a meaningful `size_hint()` for larger ranges, rather than
always just `(0, None)`. Now they return the true `(len, Some(len))`
when it fits, otherwise `(usize::MAX, None)` for overflow.
2019-03-26 10:13:48 -07:00
Chris Gregory
c709a10434 Refactor tuple comparison tests 2019-03-25 13:00:57 -04:00