]> git.lizzy.rs Git - rust.git/commitdiff
change confusing wording about discriminant
authorAlex Burka <durka42+github@gmail.com>
Tue, 14 Jun 2016 01:38:04 +0000 (21:38 -0400)
committerAlex Burka <aburka@seas.upenn.edu>
Wed, 27 Jul 2016 17:58:51 +0000 (13:58 -0400)
src/doc/book/ffi.md

index 74c99273fa262d017bc50716b59926c295c824c2..e63516e58ccfdb213128a59b028273b86c5b2536 100644 (file)
@@ -581,9 +581,9 @@ However, the language provides a workaround.
 As a special case, an `enum` is eligible for the "nullable pointer optimization" if it
 contains exactly two variants, one of which contains no data and the other contains
 a field of one of the non-nullable types listed above (or a struct containing such a type).
-This means it is represented as a single pointer, and the non-data variant is represented as a
-null pointer. This is called an "optimization", but unlike other optimizations it is guaranteed
-to apply to eligible types.
+This means no extra space is required for a discriminant; rather, the empty variant is represented
+by putting a `null` value into the non-nullable field. This is called an "optimization", but unlike
+other optimizations it is guaranteed to apply to eligible types.
 
 The most common type that takes advantage of the nullable pointer optimization is `Option<T>`,
 where `None` corresponds to `null`. So `Option<extern "C" fn(c_int) -> c_int>` is a correct way