Skip to main content

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

1use crate::docs::entry::{ConceptCategory, ConceptEntry, DescriptionEntry, DescriptionKind};
2
3pub static BYTES: ConceptEntry = ConceptEntry {
4    name: "byte",
5    descriptions: &[
6        DescriptionEntry {
7            description: "byte is an unsigned 8-bit integer, values from 0 to 255",
8            examples: &["dec byte a = 10 as byte", "dec byte b = 255 as byte"],
9            kind: DescriptionKind::Explanation,
10            title: None,
11            expected_output: &[],
12        },
13        DescriptionEntry {
14            description: "integer literals like 1, 42, 255 are int by default explicit cast should be used",
15            examples: &["dec byte x = 100 as byte  // 100 is a byte literal"],
16            kind: DescriptionKind::Explanation,
17            title: None,
18            expected_output: &[],
19        },
20        DescriptionEntry {
21            description: "use `as` to explicitly cast between byte, int, and float",
22            examples: &[
23                "dec int  x = 200 as int    // byte -> int",
24                "dec byte b = 1000 as byte  // int  -> byte (wraps: 232)",
25                "dec byte c = 3.9 as byte   // float -> byte (truncates: 3)",
26                "dec float f = 255 as float // byte -> float (255.0)",
27            ],
28            kind: DescriptionKind::Explanation,
29            title: None,
30            expected_output: &[],
31        },
32        DescriptionEntry {
33            description: "`as` is the only way to narrow int or float down to byte",
34            examples: &[
35                "dec int   n = 42\ndec byte  b = n as byte   // explicit narrow\ndec float f = n as float  // explicit widen",
36            ],
37            kind: DescriptionKind::Explanation,
38            title: None,
39            expected_output: &[],
40        },
41        DescriptionEntry {
42            description: "constant bytes use CONST byte",
43            examples: &["CONST byte MAX = 255 as byte"],
44            kind: DescriptionKind::Explanation,
45            title: None,
46            expected_output: &[],
47        },
48        DescriptionEntry {
49            description: "arrays of bytes use arr[byte]",
50            examples: &["dec arr[byte] data = [0 as byte, 127 as byte, 255 as byte]"],
51            kind: DescriptionKind::Explanation,
52            title: None,
53            expected_output: &[],
54        },
55    ],
56    summary: "",
57    category: ConceptCategory::Syntax,
58    prerequisites: &[],
59    pitfalls: &[],
60    related: &[],
61    related_stdlib: &[],
62    since: None,
63};