about summary refs log tree commit diff
path: root/src/libcore/option.rs
AgeCommit message (Collapse)AuthorLines
2019-10-28Rollup merge of #64747 - ethanboxx:master, r=CentrilMazdak Farrokhzad-3/+1
Stabilize `Option::flatten` - PR: https://github.com/rust-lang/rust/pull/60256 - Tracking issue: https://github.com/rust-lang/rust/issues/60258 @elahn > I was trying to `flat_map()` and found `map().flatten()` does the trick. This has been on nightly for 4 months, can we stabilise it? @ethanboxx > @Centril Helped me get this merged. What is the stabilization process? @Centril > @ethanboxx I'd just file a PR to stabilize it and we'll ask T-libs to FCP. So here I am. I am was unsure what number to put in `since = "-"` so I copied what someone had done in a recent PR.
2019-10-22Apply clippy::single_match suggestionMateusz Mikuła-3/+2
2019-10-20Rename the default argument 'def' to 'default'David Sinclair-2/+2
Fixes: #65492
2019-10-19Remove unneeded `ref` from docsCarol (Nichols || Goulding)-2/+2
Will reduce confusion like in https://users.rust-lang.org/t/help-understanding-the-ref-t-syntax/33779 since match ergonomics means you (almost) never have to say `ref` anymore!
2019-10-19Stabilize `Option::flatten`Ethan Brierley-3/+1
2019-10-05Rollup merge of #64708 - SimonSapin:option-deref, r=CentrilTyler Mandry-6/+2
Stabilize `Option::as_deref` and `Option::as_deref_mut` The tracking issue https://github.com/rust-lang/rust/issues/50264 still has unresolved question for the corresponding `Result` methods.
2019-09-30Fixed a misleading documentation issue #64844hman523-1/+1
2019-09-23Stabilize Option::deref and Option::deref_mutSimon Sapin-6/+2
The tracking issue https://github.com/rust-lang/rust/issues/50264 still has unresolved question for the corresponding `Result` methods.
2019-09-17Elide lifetimes in `Pin<&(mut) Self>`Taiki Endo-2/+2
2019-08-30Add missing examples for Option typeGuillaume Gomez-0/+31
2019-08-06Rollup merge of #62459 - timvermeulen:result_sum_internal_iteration, r=scottmcmMazdak Farrokhzad-2/+5
Use internal iteration in the Sum and Product impls of Result and Option This PR adds internal iteration to the `ResultShunt` iterator type underlying the `Sum` and `Product` impls of `Result`. I had to change `ResultShunt` to hold a mutable reference to an error instead, similar to `itertools::ProcessResults`, in order to be able to pass the `ResultShunt` itself by value (which is necessary for internal iteration). `ResultShunt::process` can unfortunately no longer be an associated function because that would make it generic over the lifetime of the error reference, which wouldn't work, so I turned it into the free function `process_results`. I removed the `OptionShunt` type and forwarded the `Sum` and `Product` impls of `Option` to their respective impls of `Result` instead, to avoid having to repeat the internal iteration logic.
2019-07-29Add links to None in Option docLzu Tao-2/+2
2019-07-29Use internal iteration in the Sum and Product impls of Result and OptionTim Vermeulen-2/+5
2019-07-27Refactoring use commun code between option, result and accumStargateur-40/+2
2019-07-18Use DerefMutYuki Okushi-1/+1
2019-07-18renamed `inner_deref` feature's `deref*()` methods `as_deref*()` as per ↵Brad Gibson-2/+13
discussion https://github.com/rust-lang/rust/issues/50264
2019-07-17Auto merge of #62596 - cuviper:expect_none, r=rkruppebors-1/+94
Add Option::expect_none(msg) and unwrap_none() These are `Option` analogues to `Result::expect_err` and `unwrap_err`.
2019-07-15Rollup merge of #62491 - GuillaumeGomez:fix-pin-urls-for-option, ↵Mark Rousskov-0/+4
r=QuietMisdreavus Fix Pin urls in Option documentation Fixes the following situation: ![Screenshot from 2019-07-08 13-24-59](https://user-images.githubusercontent.com/3050060/60806822-55dfdc00-a184-11e9-9ee3-279e82fc92bd.png) r? @QuietMisdreavus
2019-07-12Rollup merge of #62431 - czipperz:add-messages-to-must-use-is_-methods, ↵Mazdak Farrokhzad-2/+3
r=scottmcm Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*` r? @RalfJung
2019-07-12Add tracking issue 62633Josh Stone-2/+2
2019-07-11Make cold unwraps take &dyn DebugJosh Stone-3/+3
2019-07-11Add Option::expect_none(msg) and unwrap_none()Josh Stone-1/+94
These are `Option` analogues to `Result::expect_err` and `unwrap_err`.
2019-07-08Fix Pin urls in Option documentationGuillaume Gomez-0/+4
2019-07-08Rollup merge of #62356 - soc:topic/contains, r=CentrilMazdak Farrokhzad-0/+26
Implement Option::contains and Result::contains This increases consistency with other common data structures.
2019-07-07Implement Option::contains, Result::contains and Result::contains_errSimon Ochsenreither-0/+26
This increases consistency with other common data structures.
2019-07-07Rollup merge of #62379 - GuillaumeGomez:option-doc-links, r=QuietMisdreavusMazdak Farrokhzad-10/+22
Add missing links in Option documentation r? @rust-lang/docs
2019-07-05Wrap lineChris Gregory-1/+2
2019-07-05Add messages to Option and Result must_use for is_*Chris Gregory-2/+2
2019-07-04Add missing links in Option documentationGuillaume Gomez-10/+22
2019-07-04Rollup merge of #62344 - matklad:simplify-option, r=sfacklerMazdak Farrokhzad-9/+1
simplify Option::get_or_insert I am pretty sure that the optimized result will be the same, and it's one `unsafe` less in the stdlib!
2019-07-03simplify Option::get_or_insertAleksey Kladov-9/+1
2019-07-01Use mem::take instead of mem::replace with defaultChris Gregory-1/+1
2019-06-13Rollup merge of #60376 - lzutao:stabilize-option_xor, r=SimonSapinMazdak Farrokhzad-3/+1
Stabilize Option::xor FCP done in https://github.com/rust-lang/rust/issues/50512#issuecomment-469527554 . Closes #50512 .
2019-06-05Stabilize Option::xorLzu Tao-3/+1
2019-06-01Implement Clone::clone_from for Option.Mara Bos-1/+20
2019-04-26Add flatten option for `Option<Option<T>>`Ethan Brierley-1/+31
squashed commit
2019-04-19libcore: deny more...Mazdak Farrokhzad-2/+2
2019-04-18libcore => 2018Taiki Endo-3/+3
2019-04-08Add must_use annotations to Result::is_ok and is_errAlex Gaynor-0/+2
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.