Skip to main content

rl_lang/docs/entries/concepts/tuples/
mod.rs

1use crate::docs::entry::{ConceptCategory, ConceptEntry, DescriptionEntry, DescriptionKind};
2
3pub static TUPLES: ConceptEntry = ConceptEntry {
4    name: "tuples",
5    descriptions: &[
6        DescriptionEntry {
7            description: "a tuple holds a fixed number of values of different types",
8            examples: &[
9                "dec (int, string) p = (42, \"hello\")",
10                "dec (int, float, bool) t = (1, 3.14, true)",
11            ],
12            kind: DescriptionKind::Explanation,
13            title: None,
14            expected_output: &[],
15        },
16        DescriptionEntry {
17            description: "access tuple elements by index with `t[i]` (zero-based)",
18            examples: &[
19                "dec (int, string) p = (42, \"hello\")\nprintln(p[0])  // 42\nprintln(p[1])  // hello",
20            ],
21            kind: DescriptionKind::Explanation,
22            title: None,
23            expected_output: &[],
24        },
25        DescriptionEntry {
26            description: "destructure a tuple into named bindings in one declaration",
27            examples: &[
28                "dec int x, string y = (10, \"world\")\nprintln(x)  // 10\nprintln(y)  // world",
29                "dec int a, float b, bool c = (5, 2.5, true)",
30            ],
31            kind: DescriptionKind::Explanation,
32            title: None,
33            expected_output: &[],
34        },
35        DescriptionEntry {
36            description: "constant tuples use CONST with the tuple type",
37            examples: &["CONST (int, string) P = (0, \"origin\")"],
38            kind: DescriptionKind::Explanation,
39            title: None,
40            expected_output: &[],
41        },
42        DescriptionEntry {
43            description: "tuples can be used as array elements for homogeneous collections of structured data",
44            examples: &["dec arr[(int, string)] rows = [(1, \"one\"), (2, \"two\")]"],
45            kind: DescriptionKind::Explanation,
46            title: None,
47            expected_output: &[],
48        },
49    ],
50    summary: "",
51    category: ConceptCategory::Syntax,
52    prerequisites: &[],
53    pitfalls: &[],
54    related: &[],
55    related_stdlib: &[],
56    since: None,
57};