A lookup table, not a tutorial — Types & Units covers how unit arithmetic actually behaves. Every unit below works as a numeric literal suffix (5ft, 20kg) using its abbreviation, and as a type annotation using either the abbreviation or the full name:
#[main]
fn main() {
const a: km = 3km;
const b: kilometers = 3km;
pln(a == b);
pln(135cm + 5ft + 123in as m);
}
When two compatible-but-different units combine in an expression, the result takes on whichever of the two units is larger — mixed angles always resolve to radians specifically, regardless of size.
Length
| Unit | Full Name |
|---|
km | kilometers |
hm | hectometers |
dcm | decameters |
m | meters |
dm | decimeters |
cm | centimeters |
mm | millimeters |
um | micrometers |
nm | nanometers |
mi | miles |
yd | yards |
ft | feet |
in | inches |
Mass
| Unit | Full Name |
|---|
Gt | gigatonnes |
Mt | megatonnes |
t | tonnes |
kg | kilograms |
g | grams |
mg | milligrams |
ug | micrograms |
ng | nanograms |
pg | picograms |
Ton | tons |
lb | lbs (imperial pounds) |
oz | ounces |
Time
| Unit | Full Name |
|---|
day | days |
hr | hours |
min | minutes |
s | seconds |
ms | milliseconds |
us | microseconds |
ns | nanoseconds |
Time.now() returns a plain ms value for exactly this reason — subtracting or adding any other time unit against it just works.
Temperature
| Unit | Full Name |
|---|
K | kelvin |
C | celsius |
F | fahrenheit |
Angles
| Unit | Full Name | Range |
|---|
rad | radians | clamped to ±360° equivalent |
deg | degrees | clamped to ±360° |
prad | pradians (positive radians) | clamped to [0°, 360°) |
pdeg | pdegrees (positive degrees) | clamped to [0°, 360°) |
The positive variants exist for comparisons where sign shouldn't matter — casting -90deg to pdeg gives 270deg, not -90deg.
Memory — Decimal
| Unit | Full Name |
|---|
bit / bits | — |
byte / bytes | — |
KB | kilobytes |
MB | megabytes |
GB | gigabytes |
TB | terabytes |
PB | petabytes |
EB | exabytes |
ZB | zettabytes |
YB | yottabytes |
Memory — Binary
| Unit | Full Name |
|---|
KiB | kibibytes |
MiB | mebibytes |
GiB | gibibytes |
TiB | tebibytes |
PiB | pebibytes |
EiB | exbibytes |
ZiB | zebibytes |
YiB | yobibytes |
Stof keeps these two tables separate on purpose — MB and MiB get conflated constantly in casual use, but they're not the same size, and the gap between them widens at larger scales. If a config or a docs page you're reading says GB but means GiB (common, and usually implied by context in computing), casting to the unit you actually meant is one step either way.