|
144 | 144 | //!
|
145 | 145 | //! ## Transforming contained values
|
146 | 146 | //!
|
| 147 | +//! These transformations are from [`Option`] to [`Result`]. |
| 148 | +//! |
| 149 | +//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to |
| 150 | +//! [`Err(err)`] using the provided default `err` value |
| 151 | +//! * [`ok_or_else`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to |
| 152 | +//! a value of [`Err`] using the provided function |
| 153 | +//! * [`transpose`] transposes an [`Option`] of a [`Result`] into a |
| 154 | +//! [`Result`] of an [`Option`] |
| 155 | +//! |
| 156 | +//! These transformations are on [`Some`] values. |
| 157 | +//! |
147 | 158 | //! * [`filter`] calls the provided predicate function on the contained
|
148 | 159 | //! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]
|
149 | 160 | //! if the function returns `true`; otherwise, returns [`None`]
|
150 | 161 | //! * [`flatten`] removes one level of nesting from an
|
151 | 162 | //! [`Option<Option<T>>`]
|
152 |
| -//! * [`map`] transforms [`Some<T>`] to [`Some<U>`] using the provided |
| 163 | +//! * [`map`] transforms [`Option<T>`] to [`Option<U>`] by applying the |
| 164 | +//! provided function to the contained value of [`Some`] and leaving |
| 165 | +//! [`None`] values unchanged |
| 166 | +//! * [`map_or`] transforms [`Option<T>`] to a value of `U` by applying the |
| 167 | +//! provided function to the contained value of [`Some`], or transforms |
| 168 | +//! [`None`] to a provided default value of `U` |
| 169 | +//! * [`map_or_else`] transforms [`Option<T>`] to a value of `U` by |
| 170 | +//! applying the provided function to the contained value of [`Some`], or |
| 171 | +//! transforms [`None`] to a value of `U` using a provided fallback |
153 | 172 | //! function
|
154 |
| -//! * [`map_or`] transforms [`Some<T>`] to a value of `U` using the |
155 |
| -//! provided function, or transforms [`None`] to a provided default value |
156 |
| -//! of `U` |
157 |
| -//! * [`map_or_else`] transforms [`Some<T>`] to a value of `U` using the |
158 |
| -//! provided function, or transforms [`None`] to a value of `U` using |
159 |
| -//! another provided function |
160 |
| -//! * [`ok_or`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to |
161 |
| -//! [`Err(err)`] using the provided default `err` value |
162 |
| -//! * [`ok_or_else`] transforms [`Some(v)`] to [`Ok(v)`], and [`None`] to |
163 |
| -//! a value of [`Err<E>`] using the provided function |
164 |
| -//! * [`transpose`] transposes an [`Option`] of a [`Result`] into a |
165 |
| -//! [`Result`] of an [`Option`] |
| 173 | +//! |
| 174 | +//! These transformations combine two [`Some`] values. |
| 175 | +//! |
166 | 176 | //! * [`zip`] returns [`Some((s, o))`] if `self` is [`Some(s)`] and the
|
167 | 177 | //! provided [`Option`] value is [`Some(o)`]; otherwise, returns [`None`]
|
168 | 178 | //! * [`zip_with`] calls the provided function `f` and returns
|
|
0 commit comments