-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-type.typ
More file actions
44 lines (41 loc) · 1.24 KB
/
basic-type.typ
File metadata and controls
44 lines (41 loc) · 1.24 KB
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
39
40
41
42
43
44
#import "_lib/cram-snap.typ": theader
#columns(2)[
#table(
theader[values],
[`i32, f32, u8, isize, usize`], [??],
[`bool, anyopaque, anyerror`], [??],
[`true/false, null, undefined`], [??],
[`const bytes = "hello";`], [`@TypeOf(bytes) => *const [5:0]u8` #"\n" `bytes[5] => 0`],
[`'\u{1f4a9}', '💯'`], [`\xNN, \u{NNNNNN}`],
[`var x: u32 = undefined;
const tuple = .{ 1, 2, 3 };
x, var y: u32, const z = tuple;`], [*Destructuring*.],
)
#table(
theader[operators],
[`a orelse b`], [*Defaulting Optional Unwrap*. If a is null, returns b ("default value"), otherwise returns the unwrapped value of a.],
[`a.?`], [*Optional Unwrap*. \= `a orelse unreachable`],
[`a catch b
a catch |err| b`], [*Defaulting Error Unwrap*. If a is an error, returns b ("default value"), otherwise returns the unwrapped value of a.],
[`a == null`], [null check],
[`a.*`], [*Pointer Dereference*.],
[`&a`], [*Address Of*.],
[`a || b`], [*Error Set Merge*.],
table.cell(
colspan: 2,
[*Precedence:*\ `x() x[] x.y x.* x.?
a!b
x{}
!x -x -%x ~x &x ?x
* / % ** *% *| ||
+ - ++ +% -% +| -|
<< >> <<|
& ^ | orelse catch
== != < > <= >=
and
or
= *= *%= *|= /= %= += +%= +|= -= -%= -|= <<= <<|= >>= &= ^= |=
`],
)
)
]