about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2018-06-02Rollup merge of #51226 - gnzlbg:nonzero_align, r=SimonSapinMark Simulacrum-37/+43
Make Layout's align a NonZeroUsize This PR makes the `Layout`'s align field a `NonZeroUsize` since it cannot ever be zero, not even while building a `Layout`. It also contains some drive-by minor cleanups over the docs and the code, like updating the documented error types, or using the `size()` and `align()` methods instead of accessing the fields directly (the latter was required for the `NonZeroUsize` change anyways). r? @SimonSapin cc @Amanieu
2018-06-02Stabilize iterator_repeat_withThayne McCombs-34/+8
Fixes #48169
2018-06-02Rollup merge of #51147 - tmccombs:sliceindex, r=SimonSapinMark Simulacrum-2/+30
Stabilize SliceIndex trait. CC #35729 According to recommendations in https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
2018-06-02Rollup merge of #51124 - frewsxcv:frewsxcv-replace, r=QuietMisdreavusMark Simulacrum-4/+6
Reword {ptr,mem}::replace docs. Fixes https://github.com/rust-lang/rust/issues/50657.
2018-06-02Rollup merge of #50919 - frewsxcv:frewsxcv-epsilon, r=steveklabnikMark Simulacrum-2/+10
Provide more context for what the {f32,f64}::EPSILON values represent. Introduce the 'machine epsilon' term because if one googles 'epsilon', they might stumble upon https://en.wikipedia.org/wiki/Epsilon_numbers_(mathematics) instead of https://en.wikipedia.org/wiki/Machine_epsilon
2018-06-02Rollup merge of #50167 - fintelia:duration-nanos, r=sfacklerMark Simulacrum-0/+51
Add as_nanos function to Duration Duration has historically lacked a way to get the actual number of nanoseconds it contained as a normal Rust type because u64 was of insufficient range, and f64 of insufficient precision. The u128 type solves both issues, so I propose adding an `as_nanos` function to expose the capability.
2018-06-03impl Default for &mut strkennytm-0/+6
2018-06-02add missing inline's and optimizationsgnzlbg-4/+11
2018-06-02remove debug_assert in padding_needed_forgnzlbg-3/+0
2018-06-02Make integer methods non-const in stage0Linus Färnstrand-0/+192
2018-06-02Make most integer operations const fnsLinus Färnstrand-40/+115
2018-06-02Auto merge of #50554 - clarcharr:from_bool, r=TimNNbors-2/+39
Add From<bool> for int types Fixes #46109.
2018-06-01Reword {ptr,mem}::replace docs.Corey Farwell-4/+6
Fixes https://github.com/rust-lang/rust/issues/50657.
2018-06-01Rollup merge of #51262 - GuillaumeGomez:add-missing-whitespace, ↵Mark Simulacrum-1/+1
r=QuietMisdreavus Add missing whitespace in num example r? @QuietMisdreavus
2018-06-01Rollup merge of #51152 - crlf0710:patch-1, r=kennytmMark Simulacrum-1/+1
Replace `if` with `if and only if` in the definition dox of `Sync` The old text was: "The precise definition is: a type `T` is `Sync` if `&T` is Send." Since we've also got ``` impl<'a, T> Send for &'a T where T: Sync + ?Sized, ``` I purpose we can change the `if` to `if and only if` to make it more precise.
2018-06-01Add @ithinuel's tests from #50597Clar Charr-0/+21
2018-06-01Fix ambiguity in Result testClar Charr-2/+4
2018-06-01Add From<bool> for int typesClar Charr-0/+14
2018-06-01Simplify HashMap layout calculation by using LayoutAmanieu d'Antras-0/+8
2018-06-01Stabilize SliceIndex trait.Thayne McCombs-2/+30
Fixes #35729 According to recommendations in https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
2018-06-01Replace `if` with `if and only if` in the definition dox of `Sync`CrLF0710-1/+1
The old text was: "The precise definition is: a type T is Sync if &T is Send." Since we've also got ``` impl<'a, T> Send for &'a T where T: Sync + ?Sized, ``` I purpose we can change the `if` to `if and only if` to make it more precise.
2018-06-01Auto merge of #50836 - jsgf:arc-downcast, r=SimonSapinbors-1/+91
Arc downcast Implement `downcast` for `Arc<Any + Send + Sync>` as part of #44608, and gated by the same `rc_downcast` feature. This PR is mostly lightly-edited cut'n'paste. This has two additional changes: - The `downcast` implementation needs `Any + Send + Sync` implementations for `is` and `Debug`, and I added `downcast_ref` and `downcast_mut` for completeness/consistency. (Can these be insta-stabilized?) - At @SimonSapin's suggestion, I converted `Arc` and `Rc` to use `NonNull::cast` to avoid an `unsafe` block in each which tidied things up nicely.
2018-06-01Add missing whitespace in num exampleGuillaume Gomez-1/+1
2018-05-31Fix up Any doc examplesJeremy Fitzhardinge-3/+3
Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.
2018-05-31Add implementations for Any + Send + SyncJeremy Fitzhardinge-0/+90
Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for `Any + Send + Sync`.
2018-05-31Rollup merge of #51227 - uuttff8:master, r=dtolnayGuillaume Gomez-4/+4
mod.rs isn't beautiful I hate this spaces.
2018-05-30Add doc link from discriminant struct to function.Corey Farwell-1/+3
2018-05-30mod.rs isn't beautifuluuttff8-4/+4
2018-05-30make Layout's align a NonZeroUsizegnzlbg-36/+38
2018-05-29Auto merge of #51134 - RalfJung:from_raw_parts, r=SimonSapinbors-38/+11
extend from_raw_parts docs for slices and strs to mention alignment requirement The documentation for `str::from_raw_parts_mut` seems to not be visible because that method is private, bit I figured it could still be fixed. I also removed the reference to the no-longer-existing `str::from_raw_parts` while I was at it. Alternatively, should I remove `str::from_raw_parts_mut` completely? it is only used in `str::split_at_mut`, where it might as well be inlined.
2018-05-29Auto merge of #51142 - nickbabcock:doc-inspect, r=frewsxcvbors-2/+29
Document additional use case for iter::inspect Adds docs for `iter::inspect` showing the non-debug use case Closes #49564
2018-05-28Document additional use case for iter::inspectNick Babcock-2/+29
2018-05-28Avoid 128-bit arithmetic where possibleJonathan Behrens-2/+2
2018-05-28Auto merge of #50465 - clarcharr:wrapping, r=KodrAusbors-199/+488
Add missing Wrapping methods, use doc_comment! Re-opened version of #49393 . Finishing touches for #32463. Note that this adds `Shl` and `Shr` implementations for `Wrapping<i128>` and `Wrapping<u128>`, which were previously missed. This is technically insta-stable, but I don't know why this would be a problem.
2018-05-28get rid of str::from_raw_parts_mutRalf Jung-31/+5
str::from_raw_parts has been removed long ago because it can be obtained via str::from_utf8_unchecked and slice::from_raw_parts. The same goes for str::from_raw_parts_mut.
2018-05-28extend from_raw_parts docs for slices and strs to mention alignment requirementRalf Jung-11/+10
2018-05-28Provide more context for what the {f32,f64}::EPSILON values represent.Corey Farwell-2/+10
2018-05-27Auto merge of #51078 - GuillaumeGomez:stabilize-formatter, r=SimonSapinbors-17/+18
Stabilize Formatter alignment Fixes #27726. cc @SimonSapin
2018-05-27Stabilize Formatter alignmentGuillaume Gomez-17/+18
2018-05-27lib.rs don't beautifuluuttff8-2/+2
2018-05-26Rollup merge of #51065 - mbrubeck:docs, r=rkruppekennytm-1/+1
Update nomicon link in transmute docs The list of "invalid primitive values" has moved to a different URL within the Rustonomicon.
2018-05-26Rollup merge of #51048 - GuillaumeGomez:formatter-examples, r=QuietMisdreavuskennytm-3/+78
Add more missing examples for Formatter r? @QuietMisdreavus
2018-05-26Auto merge of #50364 - LukasKalbertodt:improve-duration-debug-impl, r=KodrAusbors-1/+246
Improve `Debug` impl of `time::Duration` Hi there! For a long time now, I was getting annoyed by the derived `Debug` impl of `Duration`. Usually, I use `Duration` to either do quick'n'dirty benchmarking or measuring the time of some operation in general. The output of the derived Debug impl is hard to parse for humans: is { secs: 0, nanos: 968360102 } or { secs: 0, nanos 98507324 } longer? So after running into the annoyance several times (sometimes building my own function to print the Duration properly), I decided to tackle this. Now the output looks like this: ``` Duration::new(1, 0) => 1s Duration::new(1, 1) => 1.000000001s Duration::new(1, 300) => 1.0000003s Duration::new(1, 4000) => 1.000004s Duration::new(1, 600000) => 1.0006s Duration::new(1, 7000000) => 1.007s Duration::new(0, 0) => 0ns Duration::new(0, 1) => 1ns Duration::new(0, 300) => 300ns Duration::new(0, 4001) => 4.001µs Duration::new(0, 600300) => 600.3µs Duration::new(0, 7000000) => 7ms ``` Note that I implemented the formatting manually and didn't use floats. No information is "lost" when printing. So `Duration::new(123_456_789_000, 900_000_001)` prints as `123456789000.900000001s`. ~~This is not yet finished~~, but I wanted to open the PR now already in order to get some feedback (maybe everyone likes the derived impl). ### Still ToDo: - [x] Respect precision ~~and width~~ parameter of the formatter (see [this comment](https://github.com/rust-lang/rust/pull/50364#issuecomment-386107107)) ### Alternatives/Decisions - Should large durations displayed in minutes, hours, days, ...? For now, I decided not to because the current formatting is close the how a `Duration` is stored. From this new `Debug` output, you can still easily see what the values of `secs` and `nanos` are. A formatting like `3h 27m 12s 9ms` might be more appropriate for a `Display` impl? - Should this rather be a `Display` impl and should `Debug` be derived? Maybe this formatting is too fancy for `Debug`? In my opinion it's not and, as already mentioned, from the current format one can still very easily determine the values for `secs` and `nanos`. - Whitespace between the number and the unit? ### Notes for reviewers - ~~The combined diff sucks. Rather review both commits individually.~~ - ~~In the unit test, I am building my own type implementing `fmt::Write` to test the output. Maybe there is already something like that which I can use?~~ - My `Debug` impl block is marked as `#[stable(...)]`... but that's fine since the derived Debug impl was stable already, right? --- ~~Apart from the main change, I moved all `time` unit tests into the `tests` directory. All other `libcore` tests are there, so I guess it was simply an oversight. Prior to this change, the `time` tests weren't run, so I guess this is kind of a bug fix. If my `Debug` impl is rejected, I can of course just send the fix as PR.~~ (this was already merged in #50466)
2018-05-25Auto merge of #51033 - coryshrmn:master, r=dtolnaybors-85/+53
stabilize RangeBounds collections_range #30877 The FCP for #30877 closed last month, with the decision to: 1. move from `collections::range::RangeArgument` to `ops::RangeBounds`, and 2. rename `start()` and `end()` to `start_bounds()` and `end_bounds()`. Simon Sapin already moved it to `ops::RangeBounds` in #49163. I renamed the functions, and removed the old `collections::range::RangeArgument` alias. This is my first Rust PR, please let me know if I can improve anything. This passes all tests for me, except the `clippy` tool (which uses `RangeArgument::start()`). I considered deprecating `start()` and `end()` instead of removing them, but the contribution guidelines indicate we can break `clippy` temporarily. I thought it was best to remove the functions, since we're worried about name collisions with `Range::start` and `end`. Closes #30877.
2018-05-25Update nomicon link in transmute docsMatt Brubeck-1/+1
The list of "invalid primitive values" has moved to a different URL within the Rustonomicon.
2018-05-24Auto merge of #50984 - cramertj:unpin-changes, r=aturonbors-2/+31
Unpin changes r? @aturon cc @withoutboats, @RalfJung, @pythonesque, #49150
2018-05-24Add more missing examples for FormatterGuillaume Gomez-3/+78
2018-05-24stabilize RangeBounds collections_range #30877Cory Sherman-85/+53
rename RangeBounds::start() -> start_bound() rename RangeBounds::end() -> end_bound()
2018-05-24Rollup merge of #50995 - fbstj:patch-1, r=cramertjkennytm-6/+4
move type out of unsafe block from https://github.com/rust-lang/rust/pull/50863#discussion_r190213000 move the union definition outside of the unsafe block as it's definition is not unsafe
2018-05-23Auto merge of #50933 - SimonSapin:anchorage, r=alexcrichtonbors-411/+204
Remove the unstable Float trait Following up to #49896 and #50629. Fixes #32110.