Skip to main content

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

1use crate::docs::entry::{ConceptCategory, ConceptEntry, DescriptionEntry, DescriptionKind};
2
3pub static CASTING: ConceptEntry = ConceptEntry {
4    name: "casting",
5    descriptions: &[
6        DescriptionEntry {
7            description: "`value as type` explicitly converts between numeric types: byte, int, and float",
8            examples: &[
9                "dec int   n = 42 as int     // byte literal -> int",
10                "dec float f = 42 as float   // byte literal -> float",
11                "dec byte  b = 200 as byte   // int -> byte",
12                "dec int   i = 3.9 as int    // float -> int (truncates: 3)",
13            ],
14            kind: DescriptionKind::Explanation,
15            title: None,
16            expected_output: &[],
17        },
18        DescriptionEntry {
19            description: "int to byte wraps on overflow (same as Rust `as u8`)",
20            examples: &[
21                "dec byte b = 256 as byte  // 0  (wraps)",
22                "dec byte c = 300 as byte  // 44 (300 - 256)",
23            ],
24            kind: DescriptionKind::Explanation,
25            title: None,
26            expected_output: &[],
27        },
28        DescriptionEntry {
29            description: "float to int truncates toward zero",
30            examples: &[
31                "dec int a = 3.9 as int   // 3",
32                "dec int b = -2.7 as int  // -2",
33            ],
34            kind: DescriptionKind::Explanation,
35            title: None,
36            expected_output: &[],
37        },
38    ],
39    summary: "",
40    category: ConceptCategory::Syntax,
41    prerequisites: &[],
42    pitfalls: &[],
43    related: &[],
44    related_stdlib: &[],
45    since: None,
46};