Built-in Types Reference
This page documents every built-in type, type constructor, and enum the Gruel compiler injects before processing user code. It is generated from the registries in [gruel-builtins] (see ADR-0020); any changes must be made in Rust, not here.
Quick Reference
Types
| Name | Ownership | Methods | Associated fns | Operators |
|---|---|---|---|---|
String | affine | 12 | 2 | ==, !=, <, <=, >, >= |
Type Constructors
| Name | Arity | Description |
|---|---|---|
Ptr | 1 | immutable raw pointer (ADR-0061) |
MutPtr | 1 | mutable raw pointer (ADR-0061) |
Ref | 1 | immutable reference (ADR-0062) |
MutRef | 1 | mutable reference (ADR-0062) |
Slice | 1 | immutable slice (ADR-0064) |
MutSlice | 1 | mutable slice (ADR-0064) |
Vec | 1 | owned, growable vector (ADR-0066) |
Enums
| Name | Variants |
|---|---|
Arch | X86_64, Aarch64 |
Os | Linux, Macos |
TypeKind | Struct, Enum, Int, Bool, Unit, Never, Array |
Ownership | Copy, Affine, Linear |
Types
String
Ownership: Affine (move semantics; dropped via __gruel_drop_String).
Layout:
| Field | Type |
|---|---|
ptr | u64 |
len | u64 |
cap | u64 |
Operators:
| Operator | Runtime symbol | Notes |
|---|---|---|
== | __gruel_str_eq | — |
!= | __gruel_str_eq | result inverted |
< | __gruel_str_cmp | — |
<= | __gruel_str_cmp | — |
> | __gruel_str_cmp | — |
>= | __gruel_str_cmp | — |
Associated functions:
String::new() -> String— runtime:String__newString::with_capacity(capacity: usize) -> String— runtime:String__with_capacity
Methods:
fn len(&self) -> usize— runtime:String__lenfn capacity(&self) -> usize— runtime:String__capacityfn is_empty(&self) -> bool— runtime:String__is_emptyfn clone(&self) -> String— runtime:String__clonefn contains(&self, needle: String) -> bool— runtime:String__containsfn starts_with(&self, prefix: String) -> bool— runtime:String__starts_withfn ends_with(&self, suffix: String) -> bool— runtime:String__ends_withfn concat(&self, other: String) -> String— runtime:String__concatfn push_str(&mut self, other: String) -> String— runtime:String__push_strfn push(&mut self, byte: u8) -> String— runtime:String__pushfn clear(&mut self) -> String— runtime:String__clearfn reserve(&mut self, additional: usize) -> String— runtime:String__reserve
Type Constructors
Built-in type constructors are written Name(arg1, arg2, ...) in type position. Sema resolves the name against the registry and lowers directly to a TypeKind without running the comptime interpreter.
Ptr(T)
immutable raw pointer (ADR-0061).
MutPtr(T)
mutable raw pointer (ADR-0061).
Ref(T)
immutable reference (ADR-0062).
MutRef(T)
mutable reference (ADR-0062).
Slice(T)
immutable slice (ADR-0064).
MutSlice(T)
mutable slice (ADR-0064).
Vec(T)
owned, growable vector (ADR-0066).
Enums
Built-in enums are injected as synthetic enum types. They are used by reflection and platform-detection intrinsics.
Arch
| Index | Variant |
|---|---|
| 0 | Arch::X86_64 |
| 1 | Arch::Aarch64 |
Os
| Index | Variant |
|---|---|
| 0 | Os::Linux |
| 1 | Os::Macos |
TypeKind
| Index | Variant |
|---|---|
| 0 | TypeKind::Struct |
| 1 | TypeKind::Enum |
| 2 | TypeKind::Int |
| 3 | TypeKind::Bool |
| 4 | TypeKind::Unit |
| 5 | TypeKind::Never |
| 6 | TypeKind::Array |
Ownership
| Index | Variant |
|---|---|
| 0 | Ownership::Copy |
| 1 | Ownership::Affine |
| 2 | Ownership::Linear |