We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 818934b commit b26e27cCopy full SHA for b26e27c
src/test/ui/generator/resume-arg-size.rs
@@ -0,0 +1,28 @@
1
+#![feature(generators)]
2
+
3
+// run-pass
4
5
+use std::mem::size_of_val;
6
7
+fn main() {
8
+ // Generator taking a `Copy`able resume arg.
9
+ let gen_copy = |mut x: usize| {
10
+ loop {
11
+ drop(x);
12
+ x = yield;
13
+ }
14
+ };
15
16
+ // Generator taking a non-`Copy` resume arg.
17
+ let gen_move = |mut x: Box<usize>| {
18
19
20
21
22
23
24
+ // Neither of these generators have the resume arg live across the `yield`, so they should be
25
+ // 4 Bytes in size (only storing the discriminant)
26
+ assert_eq!(size_of_val(&gen_copy), 4);
27
+ assert_eq!(size_of_val(&gen_move), 4);
28
+}
0 commit comments