about summary refs log tree commit diff
path: root/src/libcore/result.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1588/+0
2020-06-20Fix broken inner_deref doc tests.Eric Huss-2/+6
2020-06-18Improve document for `Result::as_deref(_mut)`Lzu Tao-16/+40
2020-04-04docs: make the description of Result::map_or more clearPonas-2/+4
2020-03-19Add Result<Result<T, E>, E>::flatten -> Result<T, E>Wim Looman-1/+33
2020-02-09Rollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPCDylan DPC-53/+59
Don't use the word "unwrap" to describe "unwrap" methods It's tautological, and "unwrap" is essentially Rust-specific jargon. I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed. This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description: > "Returns the contained `Some/Ok` value [or ...]." It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks. Previous: https://github.com/rust-lang/rust/pull/68849
2020-02-07Don't use the word 'unwrap' to describe core unwrapping functionsBrian Anderson-16/+22
It's tautological, and Rust-specific Jargon. This changes various Option/Result methods to consistently describe unwrapping behavior using the words "return", "contain", "consume". It also renames the closure argument of `Return::unwrap_or_else` to `default` to be consistent with `Option`.
2020-02-06Mark fn map_or() as eagerly evaluated.Tom A. Wagner-0/+6
In the docs for option.rs and result.rs, it is noted for all *_or() functions that they are eagerly evaluated, except for the map_or() function. This commit adds this missing documentation to the two files.
2020-02-05Reorder declarations of Result::expect_err/unwrap_err to match OptionBrian Anderson-22/+22
2020-02-05Reorder declarations of Result::export/unwrap to match OptionBrian Anderson-17/+17
2020-01-23use `diagnostic_item` and modify wordingEsteban Küber-0/+1
2020-01-11Rename Result::as_deref_ok to as_derefLzu Tao-25/+2
2020-01-11Rollup merge of #66045 - mzabaluev:unwrap-infallible, r=dtolnayYuki Okushi-0/+38
Add method Result::into_ok Implementation of https://github.com/rust-lang/rfcs/pull/2799 Tracking issue #61695
2020-01-09Rollup merge of #67966 - popzxc:core-std-matches, r=CentrilMazdak Farrokhzad-4/+1
Use matches macro in libcore and libstd This PR replaces matches like ```rust match var { value => true, _ => false, } ``` with use of `matches!` macro. r? @Centril
2020-01-08Use matches macro in libcore and libstdIgor Aleksanov-4/+1
2020-01-04Result's panics have `#[track_caller]`.Adam Perry-0/+5
2019-12-31Constify ResultLukas Lueg-3/+6
2019-12-26Remove redundant link textsMatthew Kraai-1/+1
2019-12-22Format the worldMark Rousskov-38/+58
2019-12-22Rename Result::unwrap_infallible to into_okMikhail Zabaluev-2/+2
2019-12-22Add Result::unwrap_infallibleMikhail Zabaluev-0/+38
Implementation of https://github.com/rust-lang/rfcs/pull/2799
2019-12-02stabilize Result::map_orLzu Tao-2/+1
2019-11-24Auto merge of #66322 - lzutao:consistent-result-map_or_else, r=dtolnaybors-4/+6
Stabilize Result::map_or_else Stabilized this API: ```rust impl<T, E> Result<T, E> { pub fn map_or_else<U, D: FnOnce(E) -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U { match self { Ok(t) => f(t), Err(e) => default(e), } } } ``` Closes #53268 r? @SimonSapin
2019-11-12add Result::map_orLzu Tao-0/+22
2019-11-12stabilize Result::map_or_elseLzu Tao-2/+1
2019-11-12make Result::map_or_else consistent with Option::map_or_elseLzu Tao-2/+5
2019-09-04Auto merge of #63166 - ksqsf:master, r=alexcrichtonbors-0/+81
Add Result::cloned{,_err} and Result::copied{,_err} This is a little nice addition to `Result`. 1. I'm not sure how useful are `cloned_err` and `copied_err`, but for the sake of completeness they are here. 2. Naming is similar to `map`/`map_err`. I thought about naming `cloned` as `cloned_ok` and add another method called `cloned` that clones both Ok and Err, but `cloned_ok` should be more prevalent than `cloned_both`.
2019-08-02Remove Err variants of cloned and copiedksqsf-79/+0
2019-08-01Fix doc testsksqsf-17/+17
2019-08-01Revert "cloned/copied"ksqsf-140/+4
This reverts commit 6c130817623426697d8ebdf5d505487bd11ee2f6.
2019-08-01Rename {copied,cloned} to {copied,cloned}_ok, and add {copied,cloned} to ↵ksqsf-4/+140
copy/clone both Ok and Err
2019-08-01Make these methods publicksqsf-8/+8
2019-08-01Fix issue and implksqsf-9/+9
2019-08-01Add Result::cloned{,_err} and Result::copied{,_err}ksqsf-0/+160
2019-07-29Use internal iteration in the Sum and Product impls of Result and OptionTim Vermeulen-2/+2
2019-07-27Refactoring use commun code between option, result and accumStargateur-34/+2
2019-07-18Use DerefMutYuki Okushi-1/+1
2019-07-18renamed `inner_deref` feature's `deref*()` methods `as_deref*()` as per ↵Brad Gibson-15/+48
discussion https://github.com/rust-lang/rust/issues/50264
2019-07-17Auto merge of #62596 - cuviper:expect_none, r=rkruppebors-5/+5
Add Option::expect_none(msg) and unwrap_none() These are `Option` analogues to `Result::expect_err` and `unwrap_err`.
2019-07-12Rollup merge of #62431 - czipperz:add-messages-to-must-use-is_-methods, ↵Mazdak Farrokhzad-2/+2
r=scottmcm Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*` r? @RalfJung
2019-07-11Make cold unwraps take &dyn DebugJosh Stone-5/+5
2019-07-07Implement Option::contains, Result::contains and Result::contains_errSimon Ochsenreither-0/+52
This increases consistency with other common data structures.
2019-07-05Add messages to Option and Result must_use for is_*Chris Gregory-2/+2
2019-06-01Implement Clone::clone_from for Result.Mara Bos-1/+22
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-25add missing bracesFelix S Klock II-2/+2
add missing braces analogous to those suggested by killercup
2019-03-22Expand `impl FromIterator for Result` doc to include examples of `Err` and ↵Felix S. Klock II-0/+28
early termination.
2019-03-15Option and Result: Add references to documentation of as_ref and as_mutChris Gregory-2/+2