@@ -224,6 +224,21 @@ |
|
|
224 |
224 |
//! [`Err(E)`]: Err |
225 |
225 |
//! [io::Error]: ../../std/io/struct.Error.html "io::Error" |
226 |
226 |
//! |
|
227 |
+//! # Representation |
|
228 |
+//! |
|
229 |
+//! In some cases, [`Result<T, E>`] will gain the same size, alignment, and ABI |
|
230 |
+//! guarantees as [`Option`] has. One of either the `T` or `E` type must be a |
|
231 |
+//! type that qualifies for `Option` guarantees, and the *other* type must meet |
|
232 |
+//! all of the following conditions: |
|
233 |
+//! * Is a zero-sized type with alignment 1 (a "1-ZST"). |
|
234 |
+//! * Has no fields. |
|
235 |
+//! * Does not have the #[non_exhaustive] attribute. |
|
236 |
+//! |
|
237 |
+//! For example, `Result<NonZeroI32, ()>` or `Result<(), NonZeroI32>` would both |
|
238 |
+//! have the same guarantees as `Option`. The only difference is the |
|
239 |
+//! implied semantics: `Result<NonZeroI32, ()>` is "a non-zero success value" |
|
240 |
+//! while `Result<(), NonZeroI32>` is "a non-zero error value". |
|
241 |
+//! |
227 |
242 |
//! # Method overview |
228 |
243 |
//! |
229 |
244 |
//! In addition to working with pattern matching, [`Result`] provides a |