Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf94fa6b

Browse files
committed
Some Result combinations work like an Option.
1 parentd71b3f4 commitf94fa6b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎library/core/src/result.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@
224224
//! [`Err(E)`]: Err
225225
//! [io::Error]: ../../std/io/struct.Error.html "io::Error"
226226
//!
227+
//! # Representation
228+
//!
229+
//! In some cases, [`Result<T, E>`] will gain the same size, alignment, and ABI
230+
//! guarantees as [`Option<T>`] 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<NonZeroI32>`. 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+
//!
227242
//! # Method overview
228243
//!
229244
//! In addition to working with pattern matching, [`Result`] provides a

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp