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

NameOwnershipMethodsAssociated fnsOperators
Stringaffine122==, !=, <, <=, >, >=

Type Constructors

NameArityDescription
Ptr1immutable raw pointer (ADR-0061)
MutPtr1mutable raw pointer (ADR-0061)
Ref1immutable reference (ADR-0062)
MutRef1mutable reference (ADR-0062)
Slice1immutable slice (ADR-0064)
MutSlice1mutable slice (ADR-0064)
Vec1owned, growable vector (ADR-0066)

Enums

NameVariants
ArchX86_64, Aarch64
OsLinux, Macos
TypeKindStruct, Enum, Int, Bool, Unit, Never, Array
OwnershipCopy, Affine, Linear

Types

String

Ownership: Affine (move semantics; dropped via __gruel_drop_String).

Layout:

FieldType
ptru64
lenu64
capu64

Operators:

OperatorRuntime symbolNotes
==__gruel_str_eq
!=__gruel_str_eqresult inverted
<__gruel_str_cmp
<=__gruel_str_cmp
>__gruel_str_cmp
>=__gruel_str_cmp

Associated functions:

  • String::new() -> String — runtime: String__new
  • String::with_capacity(capacity: usize) -> String — runtime: String__with_capacity

Methods:

  • fn len(&self) -> usize — runtime: String__len
  • fn capacity(&self) -> usize — runtime: String__capacity
  • fn is_empty(&self) -> bool — runtime: String__is_empty
  • fn clone(&self) -> String — runtime: String__clone
  • fn contains(&self, needle: String) -> bool — runtime: String__contains
  • fn starts_with(&self, prefix: String) -> bool — runtime: String__starts_with
  • fn ends_with(&self, suffix: String) -> bool — runtime: String__ends_with
  • fn concat(&self, other: String) -> String — runtime: String__concat
  • fn push_str(&mut self, other: String) -> String — runtime: String__push_str
  • fn push(&mut self, byte: u8) -> String — runtime: String__push
  • fn clear(&mut self) -> String — runtime: String__clear
  • fn 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

IndexVariant
0Arch::X86_64
1Arch::Aarch64

Os

IndexVariant
0Os::Linux
1Os::Macos

TypeKind

IndexVariant
0TypeKind::Struct
1TypeKind::Enum
2TypeKind::Int
3TypeKind::Bool
4TypeKind::Unit
5TypeKind::Never
6TypeKind::Array

Ownership

IndexVariant
0Ownership::Copy
1Ownership::Affine
2Ownership::Linear