doku/printers/json/print_array/
sketch.rs

1mod expand_variants;
2
3use super::*;
4
5impl<'ty> Ctxt<'_, 'ty, '_> {
6    pub(super) fn sketch_array(&mut self, ty: &'ty Type, size: Option<usize>) {
7        self.out.writeln("[");
8        self.out.inc_indent();
9
10        if self.try_expanding_variants(ty) {
11            //
12        } else if let Some(example) = self.example() {
13            let examples: Vec<_> = example.iter().collect();
14
15            for example in &examples {
16                self.nested()
17                    .with_ty(ty)
18                    .with_example(Some(*example))
19                    .print();
20
21                self.out.write_property_separator_ln();
22
23                // TODO if `size.is_some()` and this is the last example, the comma should not be printed
24            }
25
26            if size.map_or(true, |size| examples.len() < size) {
27                self.out.writeln("/* ... */");
28            }
29        } else {
30            self.nested().with_ty(ty).print();
31            self.out.write_property_separator_ln();
32            self.out.writeln("/* ... */");
33        }
34
35        self.out.dec_indent();
36        self.out.write("]");
37    }
38}