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
lcnr/Bastian Kauschke
4e7319cd3f
add unchecked math intrinsics
2019-06-03 12:59:48 +02: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
Fabian Drinck
9583398923
Fix typo in AsRef doc
2019-06-02 14:12:06 +02:00
Chris Gregory
c478efbe6a
Enable feature bound_cloned for tests
2019-06-01 22:39:13 -07:00
Mara Bos
67fd99589a
Implement Clone::clone_from for Result.
2019-06-01 09:14:59 +02:00
Mara Bos
cb12460467
Implement Clone::clone_from for Option.
2019-06-01 09:14:59 +02: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
c3824919fd
Enable feature bound_cloned
2019-05-31 21:17:32 -05: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
Chris Gregory
0772f9a920
Make Bound::cloned public
2019-05-31 11:36:28 -05:00
kennytm
be6fc6aca2
Stabilize copy_within
2019-05-31 20:02:07 +08:00
Pietro Albini
e32386d70e
Rollup merge of #61382 - OptimisticPeach:patch-1, r=Centril
...
Fixed a typo in core::convert::AsMut
Just missing a space, and added a comma to make more idiomatic.
2019-05-31 13:34:08 +02:00
Pietro Albini
562602c150
Rollup merge of #61363 - lzutao:stabilize-iter_nth_back, r=Centril
...
Stabilize iter_nth_back feature
FCP done in https://github.com/rust-lang/rust/issues/56995#issuecomment-491145691
Closes #56995
r? @Centril
2019-05-31 13:34:02 +02:00
Pietro Albini
7b83862f10
Rollup merge of #61359 - GuillaumeGomez:fix-deref-doc-links, r=Manishearth
...
Fix links in Deref documentation
Fixes #61358 .
In commonmark, the "link alias" has to be right after the link. Screenshot:
<img width="970" alt="Screenshot 2019-05-30 at 19 01 58" src="https://user-images.githubusercontent.com/3050060/58650155-3b594e00-830e-11e9-956c-4dadefa40ff0.png ">
r? @Manishearth
2019-05-31 13:34:00 +02:00
Lzu Tao
1c26bbf628
Stabilize reverse_bits feature
2019-05-31 04:43:53 +00:00
Chris Gregory
867c4a5fda
Fix compilation errors
2019-05-30 21:52:52 -05:00
OptimisticPeach
fc21f33d4d
Fixed some typos.
2019-05-30 19:37:23 -04:00
Chris Gregory
333e1ca319
Add Bound::cloned()
2019-05-30 16:46:53 -05:00
Lzu Tao
0c35c699d4
Stabilize iter_nth_back feature
2019-05-30 18:00:17 +00:00
Guillaume Gomez
436c9bee79
Fix links in Deref documentation
2019-05-30 19:06:23 +02:00
Mazdak Farrokhzad
74b359373c
Rollup merge of #60850 - SimonSapin:unguarded, r=alexcrichton
...
Stabilize RefCell::try_borrow_unguarded
Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211 . Stabilizing would help do more of the same in libraries that also have users on Stable.
2019-05-30 10:52:51 +02:00
Justin Ridgewell
3d2c4ff456
Optimize pointer alignment in utf8 validation
...
This uses (and reuses) the u8 arrays's inherent block alignment when checking whether the current index is block aligned.
I initially thought that this would just move the expensive `align_offset` call out of the while loop and replace it with a subtraction and bitwise AND. But it appears this optimizes much better, too...
before: https://rust.godbolt.org/z/WIPvWl
after: https://rust.godbolt.org/z/-jBPoW
https://github.com/jridgewell/faster-from_utf8/tree/pointer-alignment
```
test from_utf8_2_bytes_fast ... bench: 310 ns/iter (+/- 42) = 1290 MB/s
test from_utf8_2_bytes_regular ... bench: 309 ns/iter (+/- 24) = 1294 MB/s
test from_utf8_3_bytes_fast ... bench: 1,027 ns/iter (+/- 62) = 1168 MB/s
test from_utf8_3_bytes_regular ... bench: 1,513 ns/iter (+/- 611) = 793 MB/s
test from_utf8_4_bytes_fast ... bench: 1,788 ns/iter (+/- 26) = 1342 MB/s
test from_utf8_4_bytes_regular ... bench: 1,907 ns/iter (+/- 181) = 1258 MB/s
test from_utf8_all_bytes_fast ... bench: 3,463 ns/iter (+/- 97) = 1155 MB/s
test from_utf8_all_bytes_regular ... bench: 4,083 ns/iter (+/- 89) = 979 MB/s
test from_utf8_ascii_fast ... bench: 88 ns/iter (+/- 4) = 28988 MB/s
test from_utf8_ascii_regular ... bench: 88 ns/iter (+/- 8) = 28988 MB/s
test from_utf8_cyr_fast ... bench: 7,707 ns/iter (+/- 531) = 665 MB/s
test from_utf8_cyr_regular ... bench: 8,202 ns/iter (+/- 135) = 625 MB/s
test from_utf8_enwik8_fast ... bench: 1,135,756 ns/iter (+/- 84,450) = 8804 MB/s
test from_utf8_enwik8_regular ... bench: 1,145,468 ns/iter (+/- 79,601) = 8730 MB/s
test from_utf8_jawik10_fast ... bench: 12,723,844 ns/iter (+/- 473,247) = 785 MB/s
test from_utf8_jawik10_regular ... bench: 13,384,596 ns/iter (+/- 666,997) = 747 MB/s
test from_utf8_mixed_fast ... bench: 2,321 ns/iter (+/- 123) = 2081 MB/s
test from_utf8_mixed_regular ... bench: 2,702 ns/iter (+/- 408) = 1788 MB/s
test from_utf8_mostlyasc_fast ... bench: 249 ns/iter (+/- 10) = 14666 MB/s
test from_utf8_mostlyasc_regular ... bench: 276 ns/iter (+/- 5) = 13231 MB/s
```
2019-05-29 23:52:05 -04:00
Jon Gjengset
5a01b54707
Add std::mem::take as suggested in #61129
...
The name `swap_default` was suggested but rejected. @SimonSapin observed
that this operation isn't really a `swap` in the same sense as
`mem::swap`; it is a `replace`. Since `replace_default` is a bit
misleading, the "correct" name would be `replace_with_default`, which is
quite verbose.
@czipperz observed that we have precedence for using `take` to refer to
methods that replace with `Default` in `Cell::take` and `Option::take`,
so this reverts commit 99c00591c29b472c8a87c4a9342d0e0c508647a3 to
return to the original `take` method name.
The name `replace_with_default` was suggested, but was deemed too
verbose, especially given that we use `take` for methods that replace
with `Default` elsewhere.
2019-05-29 18:14:55 -04:00
Andrea Corradi
e80a37558d
Add custom nth_back for Skip
2019-05-29 22:33:38 +02:00
Oliver Scherer
18967566c7
Rollup merge of #61310 - RalfJung:mem, r=Centril
...
split libcore::mem into multiple files
r? @Centril
2019-05-29 14:41:09 +02:00
Ralf Jung
1529067a04
split libcore::mem into multiple files
2019-05-29 10:00:13 +02: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
61545b6975
Rollup merge of #60542 - timvermeulen:step_sub_usize, r=scottmcm
...
Add Step::sub_usize
Required for #54054 .
I'm aware that the `Step` trait needs a rework, but this still seems like a reasonable addition?
This currently doesn't compile because Chalk contains a type that implement this trait, and this is a breaking change. How can that be fixed?
2019-05-29 08:15:49 +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
David Tolnay
9f8d934f27
Bump Sum and Product for Option<T> to 1.37
2019-05-28 16:00:39 -07:00
Mazdak Farrokhzad
9121a73ab1
Rollup merge of #61273 - RalfJung:maybe-uninit, r=Centril
...
mention that MaybeUninit is a bit like Option
2019-05-29 00:20:06 +02:00
Ralf Jung
2bf80cf6ca
Update src/libcore/mem.rs
...
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-05-28 18:20:24 +02:00
Mazdak Farrokhzad
f91a3abade
Rollup merge of #61159 - RalfJung:ptr, r=alexcrichton
...
split core::ptr module into multiple files
Cc @Centril
2019-05-28 18:15:38 +02:00
Ralf Jung
ce7689293b
mention that MaybeUninit is a bit like Option
2019-05-28 18:04:37 +02:00
Mazdak Farrokhzad
a449bc3ad0
Rollup merge of #61237 - DevQps:expand-iterator-docs, r=Mark-Simulacrum
...
Updated the Iterator docs with information about overriding methods.
# Description
Updated the Iterator docs with information about overriding methods.
closes #60223
2019-05-28 11:49:00 +02:00
Mazdak Farrokhzad
c48835ba19
Rollup merge of #61227 - diwic:patch-2, r=Centril
...
Use .await syntax instead of await!
Tiny doc fix.
2019-05-28 11:48:56 +02:00
Mazdak Farrokhzad
08f7724355
Rollup merge of #61084 - blkerby:unreachable_doc, r=KodrAus
...
Clarify docs for unreachable! macro
Fixes #60754 .
2019-05-28 11:48:53 +02:00
bors
b71117947f
Auto merge of #61078 - pietroalbini:nightly-next, r=Centril
...
Bump nightly to 1.37.0
r? @Mark-Simulacrum
2019-05-27 23:04:54 +00:00
Christian
b560b9cd36
Updated the Iterator docs with information about overriding methods.
2019-05-27 16:17:39 +02:00
diwic
5c5f08ab93
Use .await syntax instead of await!
2019-05-27 07:27:13 +02:00
Mazdak Farrokhzad
7b8b23ceba
Rollup merge of #61161 - RalfJung:maybe-uninit, r=Centril
...
MaybeUninit doctest: remove unnecessary type ascription
2019-05-26 02:13:29 +02:00
Ralf Jung
72145ea2fe
MaybeUninit doctest: remove unnecessary type ascription
2019-05-25 09:11:20 +02:00
Ralf Jung
c2e7eb6ff0
split core::ptr module into multiple files
2019-05-25 09:03:45 +02:00
Mazdak Farrokhzad
92f1cfd039
Rollup merge of #61134 - nvzqz:reverse_bits-must_use, r=varkor
...
Annotate each `reverse_bits` with `#[must_use]`
Because the name sounds like an in-place mutation like `[T]::reverse(&mut self)`, it may be confused for one.
This change was requested at https://github.com/rust-lang/rust/issues/48763#issuecomment-493743741 .
2019-05-25 04:55:43 +02:00
Tim Vermeulen
f1d0829e20
Add Step::sub_usize
2019-05-25 02:53:08 +02:00
Tim Vermeulen
97a6c932e0
Implement nth_back for slice::{Iter, IterMut}
2019-05-25 01:47:24 +02:00
Nikolai Vazquez
035f651df7
Annotate each reverse_bits with #[must_use]
...
Because the name sounds like an in-place mutation like
`[T]::reverse(&mut self)`, it may be confused for one.
2019-05-24 22:26:34 +02:00