about summary refs log tree commit diff
path: root/src/libcore/option.rs
AgeCommit message (Collapse)AuthorLines
2019-03-25Update src/libcore/option.rsPascal Hertleif-1/+1
Co-Authored-By: pnkfelix <pnkfelix@pnkfx.org>
2019-03-22Expand `impl FromIterator for Option` doc to include example of early ↵Felix S. Klock II-0/+20
termination.
2019-03-16Rollup merge of #59231 - matklad:copied, r=Centrilkennytm-6/+2
Stabilize Option::copied closes https://github.com/rust-lang/rust/issues/57126
2019-03-16Stabilize Option::copiedAleksey Kladov-6/+2
closes https://github.com/rust-lang/rust/issues/57126
2019-03-15Option and Result: Add references to documentation of as_ref and as_mutChris Gregory-2/+2
2019-03-03Remove stray ` in the documentation for the FromIterator implementation for ↵Alexandra V-1/+1
Option
2019-02-20Rollup merge of #58553 - scottmcm:more-ihle, r=Centrilkennytm-4/+4
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-17Use more impl header lifetime elisionScott McMurray-4/+4
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-10libs: doc commentsAlexander Regueiro-3/+3
2019-01-13stabilize transpose_result in 1.33Mazdak Farrokhzad-3/+1
2018-12-26Auto merge of #56534 - xfix:copied, r=@SimonSapinbors-0/+42
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-26Add a tracking issue for Option::copiedKonrad Borowski-2/+2
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-23Rollup merge of #56939 - cramertj:pin-stabilization, r=alexcrichtonMazdak Farrokhzad-3/+3
Pin stabilization This implements the changes suggested in https://github.com/rust-lang/rust/issues/55766#issue-378417538 and stabilizes the `pin` feature. @alexcrichton also listed several "blockers" in that issue, but then in [this comment](https://github.com/rust-lang/rust/issues/55766#issuecomment-445074980) mentioned that they're more "TODO items": > In that vein I think it's fine for a stabilization PR to be posted at any time now with FCP lapsed for a week or so now. The final points about self/pin/pinned can be briefly discussed there (if even necessary, they could be left as the proposal above). Let's settle these last bits here and get this thing stabilized! :) r? @alexcrichton cc @withoutboats
2018-12-23Merge branch 'master' into copiedKonrad Borowski-1/+1
2018-12-23Improve docs for collecting into `Option`sPascal Hertleif-9/+31
Changes the original example to use more idiomatic formatting as well as `.checked_add`. Also adds a second example to show a case where the `.collect` returns `None`.
2018-12-21Stabilize PinTaylor Cramer-2/+2
2018-12-21Update Pin API to match the one proposed for stabilizationTaylor Cramer-1/+1
Remove pin::Unpin reexport and add Unpin to the prelude. Change Pin associated functions to methods. Rename get_mut_unchecked_ to get_unchecked_mut Remove impl Unpin for Pin Mark Pin repr(transparent)
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-05Add unstable Option::copied()Konrad Borowski-0/+42
2018-10-08Bump the `Option::replace` stabilize version to 1.31.0Clément Renault-1/+1
2018-10-08Stabilize the `Option::replace` methodClément Renault-3/+1
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-8/+8
2018-09-19Auto merge of #53877 - withoutboats:compositional-pin, r=aturonbors-4/+14
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-17Cleanup and fix method resolution issueTaylor Cramer-4/+2
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-06Fix invalid urlsGuillaume Gomez-7/+5
2018-09-01Update to a new pinning API.Without Boats-4/+16
2018-08-23move PinMut into pin module and export through stdNiv Kaminer-1/+1
2018-08-10Also add a `From` implementation for `&mut Option<T>` -> `Option<&mut T>'Georg Semmler-0/+7
2018-08-09Add stability attributeGeorg Semmler-0/+1
2018-08-09inline some short functionsM Farkas-Dyck-0/+4
2018-08-09Add a implementation of `From` for converting `&'a Option<T>` intoGeorg Semmler-0/+6
`Option<&'a T>`
2018-07-29resolved upstream merge conflictsBrad Gibson-5/+80
2018-07-18Rollup merge of #52218 - rivertam:patch-1, r=withoutboatskennytm-2/+4
Amend option.take examples It wasn't abundantly clear to me what `.take` returned. Perhaps this is a slightly frivolous change, but I think it's an improvement. =) Apologies if I'm not following proper procedures.
2018-07-10Amend option.take examplesBen Berman-2/+4
It wasn't abundantly clear to me what `.take` returned. Perhaps this is a slightly frivolous change, but I think it's an improvement. =) Apologies if I'm not following proper procedures.
2018-07-09Fix the documentation of `Option::replace`Clément RENAULT-1/+1
2018-07-04Implement `Option::replace` in the core libraryKerollmops-0/+27
2018-06-26Rollup merge of #51730 - MajorBreakfast:pin-get-mut-unchecked, r=withoutboatsPietro Albini-1/+1
New safe associated functions for PinMut - Add safe `get_mut` and `map` - Rename unsafe equivalents to `get_mut_unchecked` and `map_unchecked` The discussion about this starts [in this comment](https://github.com/rust-lang/rust/issues/49150#issuecomment-399604573) on the tracking issue.
2018-06-23`PinMut`: Add safe `get_mut` and rename unsafe fns to `get_mut_unchecked` ↵Josef Reinhard Brandl-1/+1
and `map_unchecked`
2018-06-20Replace unreachable! with unreachable_uncheckedMartin Glagla-3/+3
2018-05-22Add Option::as_pin_mutTaylor Cramer-0/+10
2018-05-15Add Option::xor methodClar Charr-0/+36
2018-04-30fixed some and added more testsBrad Gibson-1/+1
2018-04-26refactored to implement without traitBrad Gibson-18/+11
2018-04-26added DerefOption and DerefResult + tests to stdBrad Gibson-2/+19
2018-04-05Remove uses of option_filter featureThayne McCombs-2/+0
2018-04-01Stabilize `Option::filter`.Thayne McCombs-1/+1
Fixes #45860
2018-03-31Commit code for option size hintPhlosioneer-1/+6
2018-03-20Implement some trivial size_hints for various iteratorsPhlosioneer-0/+5
This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708.