about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2018-09-25Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichtonPietro Albini-82/+82
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-25Rollup merge of #54058 - Kerollmops:slice-dedup, r=shepmasterPietro Albini-0/+232
Introduce the partition_dedup/by/by_key methods for slices This PR propose to add three methods to the slice type, the `partition_dedup`, `partition_dedup_by` and `partition_dedup_by_key`. The two other methods are based on `slice::partition_dedup_by`. These methods take a mutable slice, deduplicates it and moves all duplicates to the end of it, returning two mutable slices, the first containing the deduplicated elements and the second all the duplicates unordered. ```rust let mut slice = [1, 2, 2, 3, 3, 2]; let (dedup, duplicates) = slice.partition_dedup(); assert_eq!(dedup, [1, 2, 3, 2]); assert_eq!(duplicates, [3, 2]); ``` The benefits of adding these methods is that it is now possible to: - deduplicate a slice without having to allocate and possibly clone elements on the heap, really useful for embedded stuff that can't allocate for example. - not loose duplicate elements, because, when using `Vec::dedup`, duplicates elements are dropped. These methods add more flexibillity to the user. Note that this is near a copy/paste of the `Vec::dedup_by` function, once this method is stable the goal is to replace the algorithm in `Vec` by the following. ```rust pub fn Vec::dedup_by<F>(&mut self, same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool { let (dedup, _) = self.as_mut_slice().partition_dedup_by(same_bucket); let len = dedup.len(); self.truncate(len); } ```
2018-09-25Rollup merge of #53518 - phungleson:fix-impl-from-for-convert, r=frewsxcvPietro Albini-0/+26
Add doc for impl From in char_convert As part of issue #51430 (cc @skade). The impl is very simple, let me know if we need to go into any details.
2018-09-25Add examples for docSon-4/+22
2018-09-25Also rename ExactChunks iterator name to ChunksExactSebastian Dröge-25/+25
2018-09-24Rename slice::exact_chunks() to slice::chunks_exact()Sebastian Dröge-59/+59
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-24Auto merge of #53783 - RalfJung:ptr-docs, r=alexcrichtonbors-549/+701
Rewrite docs for pointer methods This takes over https://github.com/rust-lang/rust/pull/51016 by @ecstatic-morse. They did most of the work, I just did some editing. However, I realized one problem: This updates the docs for the "free functions" in `core::ptr`, but it does not update the copies of these docs for the inherent methods of the `*const T` and `*mut T` types. These getting out-of-sync is certainly bad, but I also don't feel like copying all this stuff around. Instead, we should remove this redundancy. Any good ideas?
2018-09-23Auto merge of #54339 - cramertj:no-cx, r=aturonbors-424/+43
Remove spawning from task::Context r? @aturon cc https://github.com/rust-lang-nursery/wg-net/issues/56
2018-09-23Introduce the partition_dedup/by/by_key methods for slicesClément Renault-0/+232
2018-09-22address Mark-Simulacrum commentsJorge Aparicio-11/+8
2018-09-22don't deprecate mem::{uninitialized,zeroed} just yetJorge Aparicio-2/+3
2018-09-22core: fix deprecated warningsJorge Aparicio-44/+40
2018-09-22add MaybeUninit and deprecate mem::{uninitialized,zeroed}Jorge Aparicio-0/+95
2018-09-22Rollup merge of #54422 - ljedrz:simplify_first_last, r=Mark-SimulacrumPietro Albini-6/+6
Simplify slice's first(_mut) and last(_mut) with get This change makes these functions easier to read and interpret. I haven't detected any difference in performance locally. r? @Mark-Simulacrum
2018-09-22Rollup merge of #54280 - japaric:no-cas-for-thumbv6, r=alexcrichtonPietro Albini-0/+23
remove (more) CAS API from Atomic* types where not natively supported closes #54276 In PR #51953 I made the Atomic* types available on targets like thumbv6m and msp430 with the intention of *only* exposing the load and store API on those types -- the rest of the API doesn't work on those targets because the are no native instructions to implement CAS loops. Unfortunately, it seems I didn't properly cfg away all the CAS API on those targets, as evidenced in #54276. This PR amends the issue by removing the rest of the CAS API. This is technically a breaking change because *libraries* that were using this API and were being compiled for e.g. thumbv6m-none-eabi will stop compiling. However, using those libraries (before this change) in programs (binaries) would lead to linking errors when compiled for e.g. thumbv6m so this change effectively shifts a linker error in binaries to a compiler error in libraries. On a side note: extending the Atomic API is a bit error prone because of these non-cas targets. Unless the author of the change is aware of these targets and properly uses `#[cfg(atomic = "cas")]` they could end up exposing new CAS API on these targets. I can't think of a test to check that an API is not present on some target, but we could extend the `tidy` tool to check that *all* newly added atomic API has the `#[cfg(atomic = "cas")]` attribute unless it's whitelisted in `tidy` then the author of the change would have to verify if the API can be used on non-cas targets. In any case, I'd like to plug this hole ASAP. We can revisit testing in a follow-up issue / PR. r? @alexcrichton cc @mvirkkunen
2018-09-22Rollup merge of #53652 - oconnor663:copy_in_place, r=alexcrichtonPietro Albini-0/+104
define copy_within on slices This is a safe wrapper around `ptr::copy`, for regions within a single slice. Previously, safe in-place copying was only available as a side effect of `Vec::drain`. I've wanted this API a couple times in the past, and I figured I'd just whip up a PR to help discuss it. It's possible something like this exists elsewhere and I just missed it. It might also be a big enough addition to warrant an RFC, I'm not sure.
2018-09-21clarify write_bytes a bitRalf Jung-0/+4
2018-09-21Simplify slice's first(_mut) and last(_mut) with getljedrz-6/+6
2018-09-20Rollup merge of #52813 - newpavlov:duration_mul_div_extras, r=alexcrichtonkennytm-1/+120
Duration div mul extras Successor of #52556. This PR adds the following `impl`s: - `impl Mul<Duration> for u32` (to allow `10*SECOND` in addition to `SECOND*10`) - `impl Mul<f64> for Duration` (to allow `2.5*SECOND` vs `2*SECOND + 500*MILLISECOND`) - `impl Mul<Duration> for f64` - `impl MulAssign<f64> for Duration` - `impl Div<f64> for Duration` - `impl DivAssign<f64> for Duration` - `impl Div<Duration> for Duration` (`Output = f64`, can be useful e.g. for `duration/MINUTE`) `f64` is chosen over `f32` to minimize rounding errors. (52 bits fraction precision vs `Duration`'s ~94 bit)
2018-09-20add tests for copy_withinJack O'Connor-0/+47
2018-09-20define copy_within on slicesJack O'Connor-0/+57
This is a safe wrapper around ptr::copy, for regions within a single slice. Previously, safe in-place copying was only available as a side effect of Vec::drain.
2018-09-19Remove spawning from task::ContextTaylor Cramer-424/+43
2018-09-19Added tracking issue, fixed check, 1.30 -> 1.31Artyom Pavlov-8/+8
2018-09-19Auto merge of #53877 - withoutboats:compositional-pin, r=aturonbors-102/+306
Update to a new pinning API. ~~Blocked on #53843 because of method resolution problems with new pin type.~~ @r? @cramertj cc @RalfJung @pythonesque anyone interested in #49150
2018-09-18Cleanup Deref impls and add ?Sized bound to &mut T implsTaylor Cramer-4/+4
2018-09-18clarify swapRalf Jung-5/+10
2018-09-17Cleanup and fix method resolution issueTaylor Cramer-60/+102
2018-09-17rearrange for clarityRalf Jung-41/+40
2018-09-17tweaksRalf Jung-4/+27
2018-09-16Auto merge of #53910 - IsaacWoods:unify_cvoid, r=SimonSapinbors-0/+43
Move std::os::raw::c_void into libcore and re-export in libstd Implements the first part of [RFC 2521](https://github.com/rust-lang/rfcs/pull/2521). cc #53856
2018-09-16remove (more) CAS API from Atomic* types where not natively supportedJorge Aparicio-0/+23
closes #54276
2018-09-16Auto merge of #53754 - RalfJung:slice_align_to, r=alexcrichtonbors-9/+8
stabilize slice_align_to This is very hard to implement correctly, and leads to [serious bugs](https://github.com/llogiq/bytecount/pull/42) when done incorrectly. Moreover, this is needed to be able to run code that opportunistically exploits alignment on miri. So code using `align_to`/`align_to_mut` gets the benefit of a well-tested implementation *and* of being able to run in miri to test for (some kinds of) UB. This PR also clarifies the guarantee wrt. the middle part being as long as possible. Should the docs say under which circumstances the middle part could be shorter? Currently, that can only happen when running in miri.
2018-09-14Move std::os::raw::c_void into libcore and re-export in libstdIsaac Woods-0/+43
2018-09-14Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddybbors-1/+2
Add forever unstable attribute to allow specifying arbitrary scalar ranges r? @eddyb for the first commit and @nikomatsakis for the second one
2018-09-14Rollup merge of #53218 - weiznich:feature/option_ref_into, r=KodrAuskennytm-0/+14
Add a implementation of `From` for converting `&'a Option<T>` into `Option<&'a T>` I'm not sure if any annotations regarding the stabilization are needed or in general what's the correct process of adding such an impl. cc @sgrif (We have talked about this)
2018-09-13add panics section to method docsArtyom Pavlov-0/+9
2018-09-13move checks to from_float_secsArtyom Pavlov-25/+15
2018-09-13remove trailing spacesArtyom Pavlov-2/+2
2018-09-13add as_float_secs and from_float_secs methods, refactor float methodsArtyom Pavlov-36/+55
2018-09-12fix testsArtyom Pavlov-3/+3
2018-09-12fix testsArtyom Pavlov-1/+4
2018-09-12Auto merge of #53793 - toidiu:ak-stabalize, r=nikomatsakisbors-1/+0
stabilize outlives requirements https://github.com/rust-lang/rust/issues/44493 r? @nikomatsakis
2018-09-12fix doctestsArtyom Pavlov-0/+6
2018-09-12more explicit implArtyom Pavlov-1/+1
2018-09-12remove newlineArtyom Pavlov-1/+0
2018-09-12Move float ops to unstable inherent methodsArtyom Pavlov-84/+83
2018-09-12Rollup merge of #53777 - ivanbakel:result_map_or_else, r=alexcrichtonkennytm-0/+30
Implemented map_or_else for Result<T, E> Fulfills #53268 The example is ripped from `Option::map_or_else`, with the types corrected.
2018-09-11stabalize infer outlives requirements (RFC 2093).toidiu-1/+0
Co-authored-by: nikomatsakis
2018-09-11Address attribute naming and use `Bound` enumOliver Schneider-1/+1
2018-09-11Get rid of the `non_zero` lang item in favour of arbitrary range specificationsOliver Schneider-1/+2