rust/src/libcore
Yuki Okushi 961d51dcbb
Rollup merge of #66292 - lzutao:result-map_or, r=SimonSapin
add Result::map_or

This PR adds this API to make it consistent with `Option::map_or`.

```rust
impl<T, E> Result<T, E> {
    pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
        match self {
            Ok(t) => f(t),
            Err(_) => default,
        }
    }
}
```

This API is very small. We already has a similar API for `Option::map_or`.
2019-11-13 22:09:20 +09:00
..
array Snap cfgs 2019-11-12 16:36:57 -05:00
benches Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
char Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
fmt Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
future Use associated_type_bounds where applicable - closes #61738 2019-08-08 22:39:15 +02:00
hash Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
iter Rollup merge of #66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC 2019-11-13 22:09:11 +09:00
mem Rollup merge of #66217 - RalfJung:diagnostic-items, r=Centril 2019-11-10 09:27:19 +09:00
num remove vestigial comments referring to defunct numeric trait hierarchy 2019-11-08 13:51:07 -08:00
ops Snap cfgs 2019-11-12 16:36:57 -05:00
prelude Move the matches! macro to the prelude 2019-10-23 15:35:36 +02:00
ptr Snap cfgs 2019-11-12 16:36:57 -05:00
slice Rollup merge of #63793 - oli-obk:🧹, r=dtolnay 2019-11-07 14:27:20 +01:00
str Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
sync Snap cfgs 2019-11-12 16:36:57 -05:00
task Fix typo 2019-10-12 15:18:17 +02:00
tests Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
unicode it's more pythonic to use 'is not None' in python files 2019-09-06 15:14:25 +08:00
alloc.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
any.rs Halloween... time to get rid of 👻 2019-11-06 11:04:42 +01:00
ascii.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
bool.rs Snap cfgs to new beta 2019-09-25 08:42:46 -04:00
borrow.rs be more direct about borrow requirenments 2019-04-03 11:41:24 +03:00
Cargo.toml Move the matches! macro to the prelude 2019-10-23 15:35:36 +02:00
cell.rs make things ugly 2019-11-13 09:31:08 +01:00
clone.rs Snap cfgs to new beta 2019-09-25 08:42:46 -04:00
cmp.rs Migrate from #[structural_match] attribute a lang-item trait. 2019-10-25 14:52:07 +02:00
convert.rs Snap cfgs 2019-11-12 16:36:57 -05:00
default.rs Snap cfgs to new beta 2019-09-25 08:42:46 -04:00
ffi.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
hint.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
internal_macros.rs std: Remove internal definitions of cfg_if! macro 2019-06-10 10:58:44 -07:00
intrinsics.rs Auto merge of #66156 - Mark-Simulacrum:stage0-step, r=pietroalbini 2019-11-13 00:42:19 +00:00
iter_private.rs Remove licenses 2018-12-25 21:08:33 -07:00
lib.rs Snap cfgs 2019-11-12 16:36:57 -05:00
macros.rs Snap cfgs 2019-11-12 16:36:57 -05:00
marker.rs Snap cfgs 2019-11-12 16:36:57 -05:00
option.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
panic.rs Snap cfgs 2019-11-12 16:36:57 -05:00
panicking.rs Snap cfgs 2019-11-12 16:36:57 -05:00
pin.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
raw.rs Fix more tests after revert of rustdoc cfg(test) feature 2019-06-09 18:15:53 +01:00
result.rs add Result::map_or 2019-11-12 03:22:04 +00:00
time.rs Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
tuple.rs libcore => 2018 2019-04-18 14:47:35 +09:00
unit.rs libcore => 2018 2019-04-18 14:47:35 +09:00