Skip to content

Commit 058f08d

Browse files
RalfJungtraviscross
authored andcommitted
have Result docs match ABI docs
1 parent 781432e commit 058f08d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

library/core/src/result.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,16 @@
232232
//!
233233
//! In some cases, [`Result<T, E>`] comes with size, alignment, and ABI guarantees.
234234
//! Specifically, one of either the `T` or `E` type must be a type that qualifies for the `Option`
235-
//! [representation guarantees][opt-rep] (let's call that type `I`), and the *other* type must meet
236-
//! all of the following conditions:
237-
//! * Is a zero-sized type with alignment 1 (a "1-ZST").
238-
//! * Is either a struct/tuple with no fields, or an enum with no variants.
239-
//! * Does not have the `#[non_exhaustive]` attribute.
235+
//! [representation guarantees][opt-rep] (let's call that type `I`), and the *other* type
236+
//! is a zero-sized type with alignment 1 (a "1-ZST").
240237
//!
241238
//! If that is the case, then `Result<T, E>` has the same size, alignment, and [function call ABI]
242239
//! as `I` (and therefore, as `Option<I>`). If `I` is `T`, it is therefore sound to transmute `t: I`
243240
//! to `Result<T, E>` (which will produce `Ok(t)`), and to transmute `Ok(t): Result<T, E>` to `I`
244241
//! (which will produce `t`). If `I` is `E`, the same applies with `Ok` replaced by `Err`.
245242
//!
246-
//! For example, `NonZeroI32` qualifies for the `Option` representation
247-
//! guarantees, and `()` is a zero-sized type with alignment 1, no fields, and
248-
//! it isn't `non_exhaustive`. This means that both `Result<NonZeroI32, ()>` and
243+
//! For example, `NonZeroI32` qualifies for the `Option` representation guarantees, and `()` is a
244+
//! zero-sized type with alignment 1. This means that both `Result<NonZeroI32, ()>` and
249245
//! `Result<(), NonZeroI32>` have the same size, alignment, and ABI
250246
//! as `NonZeroI32` (and `Option<NonZeroI32>`). The only difference is the implied semantics:
251247
//! * `Option<NonZeroI32>` is "a non-zero i32 might be present"

0 commit comments

Comments
 (0)