Skip to content

Commit 76cd60a

Browse files
committed
Revise extending tuple struct constructor examples
The example for the tuple enum variant constructor should go above the example that already uses a tuple enum variant constructor in a nested manner. This also matches the order in the list of extending expressions above -- the list items for tuple struct constructors and tuple enum variant constructors come after tuple expressions and before block expressions. For demonstrating a tuple enum variant constructor, it's better to use `Some(_)` than to define one; `Option<T>` is well known enough. For the tuple struct that we need to define, let's use a short name like `W<T>` here rather than `TupleStruct<T>` (and show its definition). When I see a name like `TupleStruct`, it takes me a moment to confirm it's just a name and not more than that. We use this `W<T>(T)` "wrapper" tuple struct definition elsewhere in the Reference. As a wording matter, we say "argument to" rather than "argument of". Similarly, something isn't an argument to a tuple struct but an argument to the tuple struct constructor, so let's say that.
1 parent 5acc59f commit 76cd60a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/destructors.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,12 @@ let x = &temp() as &dyn Send; // Operand of cast.
524524
# x;
525525
let x = (&*&temp(),); // Operand of tuple constructor.
526526
# x;
527-
let x = { [Some(&temp())] }; // Final expr of block.
527+
struct W<T>(T);
528+
let x = W(&temp()); // Argument to tuple struct constructor.
528529
# x;
529-
# struct TupleStruct<T>(T);
530-
let x = TupleStruct(&temp()); // Argument of tuple struct.
530+
let x = Some(&temp()); // Argument to tuple enum variant constructor.
531531
# x;
532-
# enum Enum<T> {
533-
# TupleVariant(T),
534-
# }
535-
let x = Enum::TupleVariant(&temp()); // Argument of tuple enum variant.
532+
let x = { [Some(&temp())] }; // Final expr of block.
536533
# x;
537534
let x = const { &temp() }; // Final expr of `const` block.
538535
# x;

0 commit comments

Comments
 (0)