Skip to content

Commit 20a0062

Browse files
committed
updates based on reviews
Fix an error in `map_or_else`. Use more descriptive text for "don't care" in truth tables. Make minor corrections to truth tables. Rename `makeiter` to `make_iter` in examples.
1 parent 738bc2a commit 20a0062

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

core/src/option.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
//! * [`map_or`] transforms [`Some<T>`] to a value of `U` using the
149149
//! provided function, or transforms [`None`] to a provided default value
150150
//! of `U`
151-
//! * [`map_or_else`] transforms [`Some<T>`] to [`Some<U>`] using the
151+
//! * [`map_or_else`] transforms [`Some<T>`] to a value of `U` using the
152152
//! provided function, or transforms [`None`] to a value of `U` using
153153
//! another provided function
154154
//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to
@@ -179,11 +179,12 @@
179179
//!
180180
//! | method | self | input | output |
181181
//! |---------|-----------|-----------|-----------|
182-
//! | [`and`] | N/A | `None` | `None` |
182+
//! | [`and`] | `None` | (ignored) | `None` |
183+
//! | [`and`] | `Some(x)` | `None` | `None` |
183184
//! | [`and`] | `Some(x)` | `Some(y)` | `Some(y)` |
184185
//! | [`or`] | `None` | `None` | `None` |
185186
//! | [`or`] | `None` | `Some(y)` | `Some(y)` |
186-
//! | [`or`] | `Some(x)` | N/A | `Some(x)` |
187+
//! | [`or`] | `Some(x)` | (ignored) | `Some(x)` |
187188
//! | [`xor`] | `None` | `None` | `None` |
188189
//! | [`xor`] | `None` | `Some(y)` | `Some(y)` |
189190
//! | [`xor`] | `Some(x)` | `None` | `Some(x)` |
@@ -199,15 +200,15 @@
199200
//!
200201
//! | method | self | function input | function result | output |
201202
//! |--------------|-----------|----------------|-----------------|-----------|
202-
//! | [`and_then`] | `None` | N/A | (not evaluated) | `None` |
203+
//! | [`and_then`] | `None` | (not provided) | (not evaluated) | `None` |
203204
//! | [`and_then`] | `Some(x)` | `x` | `None` | `None` |
204205
//! | [`and_then`] | `Some(x)` | `x` | `Some(y)` | `Some(y)` |
205-
//! | [`filter`] | `None` | N/A | (not evaluated) | `None` |
206+
//! | [`filter`] | `None` | (not provided) | (not evaluated) | `None` |
206207
//! | [`filter`] | `Some(x)` | `x` | `false` | `None` |
207208
//! | [`filter`] | `Some(x)` | `x` | `true` | `Some(x)` |
208-
//! | [`or_else`] | `None` | N/A | `None` | `None` |
209-
//! | [`or_else`] | `None` | N/A | `Some(y)` | `Some(y)` |
210-
//! | [`or_else`] | `Some(x)` | N/A | (not evaluated) | `Some(x)` |
209+
//! | [`or_else`] | `None` | (not provided) | `None` | `None` |
210+
//! | [`or_else`] | `None` | (not provided) | `Some(y)` | `Some(y)` |
211+
//! | [`or_else`] | `Some(x)` | (not provided) | (not evaluated) | `Some(x)` |
211212
//!
212213
//! [`and`]: Option::and
213214
//! [`and_then`]: Option::and_then
@@ -266,11 +267,11 @@
266267
//! let yep = Some(42);
267268
//! let nope = None;
268269
//!
269-
//! fn makeiter(opt: Option<i32>) -> impl Iterator<Item = i32> {
270+
//! fn make_iter(opt: Option<i32>) -> impl Iterator<Item = i32> {
270271
//! (0..4).chain(opt.into_iter()).chain(4..8)
271272
//! }
272-
//! println!("{:?}", makeiter(yep).collect::<Vec<_>>());
273-
//! println!("{:?}", makeiter(nope).collect::<Vec<_>>());
273+
//! println!("{:?}", make_iter(yep).collect::<Vec<_>>());
274+
//! println!("{:?}", make_iter(nope).collect::<Vec<_>>());
274275
//! ```
275276
//!
276277
//! If we try to do the same thing, but using pattern matching, we can't
@@ -281,7 +282,7 @@
281282
//! # use std::iter::{empty, once};
282283
//! // This won't compile because all possible returns from the function
283284
//! // must have the same concrete type.
284-
//! fn makeiter(opt: Option<i32>) -> impl Iterator<Item = i32> {
285+
//! fn make_iter(opt: Option<i32>) -> impl Iterator<Item = i32> {
285286
//! match opt {
286287
//! Some(x) => return (0..4).chain(once(x)).chain(4..8),
287288
//! None => return (0..4).chain(empty()).chain(4..8)

core/src/result.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,14 @@
239239
//! [`Result<U, E>`] value having a different inner type `U` than
240240
//! [`Result<T, E>`].
241241
//!
242-
//! | method | self | input | output |
243-
//! |---------|----------|----------|----------|
244-
//! | [`and`] | N/A | `Err(e)` | `Err(e)` |
245-
//! | [`and`] | `Ok(x)` | `Ok(y)` | `Ok(y)` |
246-
//! | [`or`] | `Err(e)` | `Err(d)` | `Err(d)` |
247-
//! | [`or`] | `Err(e)` | `Ok(y)` | `Ok(y)` |
248-
//! | [`or`] | `Ok(x)` | N/A | `Ok(x)` |
242+
//! | method | self | input | output |
243+
//! |---------|----------|-----------|----------|
244+
//! | [`and`] | `Err(e)` | (ignored) | `Err(e)` |
245+
//! | [`and`] | `Ok(x)` | `Err(d)` | `Err(d)` |
246+
//! | [`and`] | `Ok(x)` | `Ok(y)` | `Ok(y)` |
247+
//! | [`or`] | `Err(e)` | `Err(d)` | `Err(d)` |
248+
//! | [`or`] | `Err(e)` | `Ok(y)` | `Ok(y)` |
249+
//! | [`or`] | `Ok(x)` | (ignored) | `Ok(x)` |
249250
//!
250251
//! The [`and_then`] and [`or_else`] methods take a function as input, and
251252
//! only evaluate the function when they need to produce a new value. Only
@@ -254,12 +255,12 @@
254255
//!
255256
//! | method | self | function input | function result | output |
256257
//! |--------------|----------|----------------|-----------------|----------|
257-
//! | [`and_then`] | `Err(e)` | N/A | (not evaluated) | `Err(e)` |
258+
//! | [`and_then`] | `Err(e)` | (not provided) | (not evaluated) | `Err(e)` |
258259
//! | [`and_then`] | `Ok(x)` | `x` | `Err(d)` | `Err(d)` |
259260
//! | [`and_then`] | `Ok(x)` | `x` | `Ok(y)` | `Ok(y)` |
260261
//! | [`or_else`] | `Err(e)` | `e` | `Err(d)` | `Err(d)` |
261262
//! | [`or_else`] | `Err(e)` | `e` | `Ok(y)` | `Ok(y)` |
262-
//! | [`or_else`] | `Ok(x)` | N/A | (not evaluated) | `Ok(x)` |
263+
//! | [`or_else`] | `Ok(x)` | (not provided) | (not evaluated) | `Ok(x)` |
263264
//!
264265
//! [`and`]: Result::and
265266
//! [`and_then`]: Result::and_then

0 commit comments

Comments
 (0)