Skip to content

Commit 5276b29

Browse files
committed
change confusing wording about discriminant
1 parent fae3335 commit 5276b29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/doc/book/ffi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ However, the language provides a workaround.
581581
As a special case, an `enum` is eligible for the "nullable pointer optimization" if it
582582
contains exactly two variants, one of which contains no data and the other contains
583583
a field of one of the non-nullable types listed above (or a struct containing such a type).
584-
This means it is represented as a single pointer, and the non-data variant is represented as a
585-
null pointer. This is called an "optimization", but unlike other optimizations it is guaranteed
586-
to apply to eligible types.
584+
This means no extra space is required for a discriminant; rather, the empty variant is represented
585+
by putting a `null` value into the non-nullable field. This is called an "optimization", but unlike
586+
other optimizations it is guaranteed to apply to eligible types.
587587

588588
The most common type that takes advantage of the nullable pointer optimization is `Option<T>`,
589589
where `None` corresponds to `null`. So `Option<extern "C" fn(c_int) -> c_int>` is a correct way

0 commit comments

Comments
 (0)