GDScript for Rust Developers
Move from Rust to Godot 4 GDScript through 48 multi-file tasks: typing, ownership, script classes, callables, signals and failure contracts. Build a connected stock depot and port two Rust programs.
Rust and GDScript side by side
The same program in Rust and in GDScript, from the lessons of this course.
Text and Comments
Rust enters main and println! formats arguments through a format string. GDScript enters the runner Node through _ready and print concatenates arguments without inserted spaces. Rust uses braces and // comments; GDScript uses indentation and #. A quoted hash…
Rust1 2fn main() { println!("tag {}",7); println!("# data"); }GDScript1extends Node2 3func _ready() -> void:4 print("tag", 7)5 print("# data")Branches and Values
Rust if can return a value and requires a bool condition; both branches must have compatible types. GDScript uses indented blocks and yes if condition else no for expression selection. Ordered branch chains stop at the first match. Return early when invalid…
Rust1 2fn main() { let n=-2; let direction=if n<0 {"west"} else {"east"}; println!("{direction}"); }GDScript1extends Node2 3func _ready() -> void:4 var n: int = -25 print("west" if n < 0 else "east")Array Operations
Rust Vec<T> and GDScript Array are growable sequences with zero-based indices. Rust indices use usize and do not provide negative-from-end syntax; GDScript permits negative indices. Vec::pop returns Option<T> and needs explicit empty handling, while bounds…
Rust1 2fn main() { let mut items=vec![3]; items.push(8); let removed=items.pop().expect("nonempty"); println!("{} {}",removed,items.len()); }GDScript1extends Node2 3func _ready() -> void:4 var items: Array = [3]5 items.append(8)6 var removed = items.pop_back()7 print("%d %d" % [removed,items.size()])String Operations
Rust str::replace returns an owned String and leaves its borrowed source unchanged. GDScript String.replace also returns a new value. Rust mutable String has separate in-place operations whose borrow and UTF-8 boundary contracts matter. Choose literal…
Rust1 2fn main() { let s="a-b-a"; let t=s.replace("-", "/"); println!("{s} {t}"); }GDScript1extends Node2 3func _ready() -> void:4 var s: String = "a-b-a"5 var t: String = s.replace("-","/")6 print(s," ",t)Scripts as Classes
Rust structs and impl blocks define data and behavior; constructing a struct ordinarily creates an owned value. GDScript scripts define reference-like objects and class_name registers their types. Rc<RefCell<T>> explicitly models shared mutable identity in…
Rust1pub struct Token { pub text:String }GDScript1class_name DemoToken2extends RefCounted3var text: String = "blue"Inheritance and Super
Rust does not provide struct inheritance. Composition and traits express reuse and shared contracts, while GDScript extends one base class and uses super to call inherited behavior. The Rust Child below contains a Base and delegates explicitly; that is…
Rust1pub struct Base;2impl Base { pub fn label(&self)->&str { "base" } }GDScript1class_name DemoBase2extends RefCounted3func label() -> String:4 return "base"
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsScripts and Scalar Values
6 lessonsFlow and Functions
6 lessonsCollection Ownership
6 lessonsText and Callable Values
3 lessonsObjects and State
5 lessonsObject Relationships
5 lessonsEvents and Failure
5 lessonsBoundaries and Lifetimes
6 lessonsConnected Stock Depot
Project4 lessonsFinal Ports
2 lessonsFrequently asked questions
Who is GDScript for Rust Developers for?
For people who already write Rust and want to learn GDScript. Each lesson starts from Rust you know and shows how GDScript does the same thing, so you skip the beginner basics.
Do I need to know GDScript already?
No. The course starts with your first GDScript program. You need Rust basics: variables, conditions, loops, functions and collections.
How many lessons does GDScript for Rust Developers have?
GDScript for Rust Developers contains 48 interactive lessons you can complete at your own pace.
What does GDScript for Rust Developers cover?
The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.
Is GDScript 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.