Luau for Rust Developers
Transfer Rust ownership, collections and traits to Luau tables, closures and typed signatures. Practice runtime validation, relative modules and metatable objects, build a stock ledger and port two Rust programs.
Rust and Luau side by side
The same program in Rust and in Luau, from the lessons of this course.
Print and Comment
Rust println! formats arguments through formatting traits and macros. Luau print converts values at runtime and separates multiple arguments with tabs. Assemble one string using .. when exact spacing is required. Rust string addition has ownership and…
Rust1fn main() {2println!("Hi, {}", "Ada");3}Luau1local name = "Ada"2print(`Hi, {name}`)Missing Fields and Optionals
Rust Option represents absence and safe references are non-null. A map can retain a key whose value is None, with lookup distinguishing absence from that stored variant. Luau nil removes the table association instead. False remains a stored value. Use a…
Rust1fn main() {2let values=std::collections::HashMap::from([("x",None::<i32>)]); println!("{}",values.contains_key("x"));3}Luau1local d = {x = nil}2print(d.x == nil)Inclusive Numeric Loops
Rust half-open ranges exclude the end while inclusive ranges use a different syntax. Luau numeric for includes its limit and takes an optional step, defaulting to one. Descending traversal requires a negative step. Translate the actual visited values and…
Rust1fn main() {2let mut total=0; for i in 1..4 {total+=i;} println!("{}",total);3}Luau1local total = 02for i = 1, 3 do total = total + i end3print(total)Functions and Returns
Rust signatures enforce argument types and borrowing rules, with &mut parameters able to update caller-owned values. Luau annotations describe static expectations but this runner does not invoke the analyzer. Scalar rebinding remains local; table fields can…
Rust1fn twice(n:i32)->i32 {n*2}2fn main() {3println!("{}",twice(4));4}Luau1local function twice(x: number): number return x * 2 end2print(twice(4))Lists as Dense Tables
Rust Vec.remove takes a zero-based index and shifts later values while mutable borrowing controls access. Luau table.remove similarly shifts a sequence, but uses one-based positions without borrow tracking. Assigning nil to a middle field leaves a hole…
Rust1fn main() {2let mut values=vec!["a","b","c"]; values.remove(1); println!("{}",values.join(","));3}Luau1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))Sorting and Comparators
Rust slice sorting mutates through mutable access and comparison APIs may use Ordering values or key selectors. Luau table.sort also mutates but expects a strict Boolean ordering and returns no result. Keep the sequence reference instead of assigning the sort…
Rust1fn main() {2let mut values=vec![3,1,2]; values.sort(); println!("{}",values[0]);3}Luau1local a={3,1,2}2table.sort(a)3print(a[1])
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst Luau Programs
6 lessonsValues and Decisions
5 lessonsIteration and Flow
5 lessonsFunctions and Closures
5 lessonsTables as Collections
5 lessonsOrdering, Modules and Errors
5 lessonsObjects and Owned State
5 lessonsComposition and Object Lookup
6 lessonsProject: Stock Ledger
4 lessonsFinal Source Ports
2 lessonsFrequently asked questions
Who is Luau for Rust Developers for?
For people who already write Rust and want to learn Luau. Each lesson starts from Rust you know and shows how Luau does the same thing, so you skip the beginner basics.
Do I need to know Luau already?
No. The course starts with your first Luau program. You need Rust basics: variables, conditions, loops, functions and collections.
How many lessons does Luau for Rust Developers have?
Luau for Rust Developers contains 48 interactive lessons you can complete at your own pace.
What does Luau for Rust Developers cover?
The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.
Is Luau for Rust Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.