1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod expand_variants;

use super::*;

impl<'ty> Ctxt<'_, 'ty, '_> {
    pub(super) fn sketch_array(&mut self, ty: &'ty Type, size: Option<usize>) {
        self.out.writeln("[");
        self.out.inc_indent();

        if self.try_expanding_variants(ty) {
            //
        } else if let Some(example) = self.example() {
            let examples: Vec<_> = example.iter().collect();

            for example in &examples {
                self.nested()
                    .with_ty(ty)
                    .with_example(Some(*example))
                    .print();

                self.out.writeln(",");

                // TODO if `size.is_some()` and this is the last example, the comma should not be printed
            }

            if size.map_or(true, |size| examples.len() < size) {
                self.out.writeln("/* ... */");
            }
        } else {
            self.nested().with_ty(ty).print();
            self.out.writeln(",");
            self.out.writeln("/* ... */");
        }

        self.out.dec_indent();
        self.out.write("]");
    }
}