Brian Anderson
db9b578b71
Reorder declarations of Result::expect_err/unwrap_err to match Option
2020-02-05 16:31:12 +08:00
Brian Anderson
c00d8aa517
Reorder declarations of Result::export/unwrap to match Option
2020-02-05 16:28:13 +08:00
Esteban Küber
6eaf59dfc8
use diagnostic_item and modify wording
2020-01-23 11:51:56 -08:00
Lzu Tao
a5f42397be
Rename Result::as_deref_ok to as_deref
2020-01-11 03:08:40 +00:00
Yuki Okushi
2dbcf0841a
Rollup merge of #66045 - mzabaluev:unwrap-infallible, r=dtolnay
...
Add method Result::into_ok
Implementation of https://github.com/rust-lang/rfcs/pull/2799
Tracking issue #61695
2020-01-11 04:50:45 +09:00
Mazdak Farrokhzad
5ea69781f4
Rollup merge of #67966 - popzxc:core-std-matches, r=Centril
...
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-09 00:22:10 +01:00
Igor Aleksanov
f720469fd0
Use matches macro in libcore and libstd
2020-01-08 07:10:28 +03:00
Adam Perry
7a6af7eb0e
Result's panics have #[track_caller].
2020-01-04 19:52:37 -08:00
Lukas Lueg
954c432a87
Constify Result
2019-12-31 15:13:37 +01:00
Matthew Kraai
21e636f188
Remove redundant link texts
2019-12-26 05:04:46 -08:00
Mark Rousskov
a06baa56b9
Format the world
2019-12-22 17:42:47 -05:00
Mikhail Zabaluev
6f0672c08b
Rename Result::unwrap_infallible to into_ok
2019-12-22 08:35:10 +02:00
Mikhail Zabaluev
a20013b129
Add Result::unwrap_infallible
...
Implementation of
https://github.com/rust-lang/rfcs/pull/2799
2019-12-22 08:05:52 +02:00
Lzu Tao
8cae411ae3
stabilize Result::map_or
2019-12-02 06:25:12 +00:00
bors
7d761fe046
Auto merge of #66322 - lzutao:consistent-result-map_or_else, r=dtolnay
...
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-24 07:37:01 +00:00
Lzu Tao
e8f3a9ffbe
add Result::map_or
2019-11-12 03:22:04 +00:00
Lzu Tao
c06a8ea727
stabilize Result::map_or_else
2019-11-12 03:09:10 +00:00
Lzu Tao
2de6c35d46
make Result::map_or_else consistent with Option::map_or_else
2019-11-12 03:08:19 +00:00
bors
5f42f3e108
Auto merge of #63166 - ksqsf:master, r=alexcrichton
...
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-09-04 07:47:08 +00:00
ksqsf
61e5286635
Remove Err variants of cloned and copied
2019-08-02 13:58:55 +08:00
ksqsf
9733f0d163
Fix doc tests
2019-08-01 19:18:03 +08:00
ksqsf
4b2f598986
Revert "cloned/copied"
...
This reverts commit 6c13081762 .
2019-08-01 13:38:23 +08:00
ksqsf
6c13081762
Rename {copied,cloned} to {copied,cloned}_ok, and add {copied,cloned} to copy/clone both Ok and Err
2019-08-01 02:35:14 +08:00
ksqsf
5a36b0dba1
Make these methods public
2019-08-01 01:09:07 +08:00
ksqsf
c784720f3a
Fix issue and impl
2019-08-01 00:55:36 +08:00
ksqsf
a0ab5a3651
Add Result::cloned{,_err} and Result::copied{,_err}
2019-08-01 00:26:47 +08:00
Tim Vermeulen
2e41ba8742
Use internal iteration in the Sum and Product impls of Result and Option
2019-07-29 02:40:50 +02:00
Stargateur
3334802c83
Refactoring use commun code between option, result and accum
2019-07-27 02:17:56 +02:00
Yuki Okushi
f2a97210b2
Use DerefMut
2019-07-18 15:18:41 +09:00
Brad Gibson
d1aca3aea5
renamed inner_deref feature's deref*() methods as_deref*() as per discussion https://github.com/rust-lang/rust/issues/50264
2019-07-18 15:17:30 +09:00
bors
d56128d291
Auto merge of #62596 - cuviper:expect_none, r=rkruppe
...
Add Option::expect_none(msg) and unwrap_none()
These are `Option` analogues to `Result::expect_err` and `unwrap_err`.
2019-07-17 08:29:02 +00:00
Mazdak Farrokhzad
f169b15e1d
Rollup merge of #62431 - czipperz:add-messages-to-must-use-is_-methods, r=scottmcm
...
Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*`
r? @RalfJung
2019-07-12 22:46:41 +02:00
Josh Stone
955979ab28
Make cold unwraps take &dyn Debug
2019-07-11 12:40:38 -07:00
Simon Ochsenreither
6f76da494b
Implement Option::contains, Result::contains and Result::contains_err
...
This increases consistency with other common data structures.
2019-07-07 16:50:44 +02:00
Chris Gregory
145385e7c3
Add messages to Option and Result must_use for is_*
2019-07-05 20:57:25 -07:00
Mara Bos
67fd99589a
Implement Clone::clone_from for Result.
2019-06-01 09:14:59 +02:00
Mazdak Farrokhzad
dbfbadeac4
libcore: deny more...
2019-04-19 01:37:12 +02:00
Taiki Endo
360432f1e8
libcore => 2018
2019-04-18 14:47:35 +09:00
Alex Gaynor
ce5d69480a
Add must_use annotations to Result::is_ok and is_err
2019-04-08 12:58:09 -04:00
Felix S Klock II
0e83e96852
add missing braces
...
add missing braces analogous to those suggested by killercup
2019-03-25 11:50:11 +01:00
Felix S. Klock II
d5a61c0be2
Expand impl FromIterator for Result doc to include examples of Err and early termination.
2019-03-22 12:44:08 +01:00
Chris Gregory
9a61580d40
Option and Result: Add references to documentation of as_ref and as_mut
2019-03-15 16:42:10 -04:00
Chris Gregory
6b88c90504
impl FromIterator for Result: Use assert_eq! instead of assert!
2019-03-11 21:04:34 -04:00
Alexander Regueiro
99ed06eb88
libs: doc comments
2019-02-10 23:57:25 +00:00
Mazdak Farrokhzad
6d7a4a6e4c
stabilize transpose_result in 1.33
2019-01-13 06:15:44 +01:00
Mark Rousskov
2a663555dd
Remove licenses
2018-12-25 21:08:33 -07:00
Scott McMurray
0a3bd9b6ab
Use impl_header_lifetime_elision in libcore
2018-09-29 21:33:35 -07:00
kennytm
4f62077a2c
Rollup merge of #53777 - ivanbakel:result_map_or_else, r=alexcrichton
...
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-12 12:17:25 +08:00
Guillaume Gomez
c1ad1b0338
Fix invalid urls
2018-09-06 23:32:30 +02:00
Isaac van Bakel
79408c3f32
Added feature attribute to example code in map_or_else doc
2018-08-30 00:51:09 +01:00