Menu
CoddyTech
Course

Rust for Go Developers

Bring your Go experience to Rust ownership, borrowed slices, enums, errors, methods, and traits. Complete 48 multi-file exercises, build a parcel depot, and port two complete Go programs.

Go and Rust side by side

The same program in Go and in Rust, from the lessons of this course.

  1. Output and Comments

    Go uses the imported fmt package for formatted output. Rust has formatting macros in its prelude: println! adds a newline, while print! does not. The exclamation mark distinguishes a macro call from an ordinary function call.

    Go
    1package main2import "fmt"3func main() {4    // One line, two fields.5    fmt.Printf("orbit %d %s\n", 4, "east")6}
    Rust
    1fn main() {2    // One line, two fields.3    println!("orbit {} {}", 4, "east");4}
  2. Boolean Conditions

    Go conditions require booleans, and Rust does too. Neither language treats an integer count as an implicit truth value. Comparisons produce bool values, and && and || short-circuit from left to right.

    Go
    1package main2import "fmt"3func main() {4    text := ""5    found := len(text) > 0 && text[0] == '#'6    fmt.Println(found)7}
    Rust
    1fn main() {2    let text = "";3    let found = !text.is_empty() && text.as_bytes()[0] == b'#';4    println!("{}", found);5}
  3. Functions and Returns

    Go places result types after the parameter list; Rust uses ->. Both languages require parameter types in function declarations. Rust can return a final expression without return or a semicolon. Explicit return is useful for an early exit.

    Go
    1package main2import "fmt"3func swapFlags(a, b bool) (bool, bool) { return b, a }4func main() { x, y := swapFlags(true, false); fmt.Println(x, y) }
    Rust
    1fn swap_flags(a: bool, b: bool) -> (bool, bool) { (b, a) }2fn main() {3    let (x, y) = swap_flags(true, false);4    println!("{} {}", x, y);5}
  4. Ownership and Moves

    A Go string assignment copies a string descriptor, and both variables remain usable. Go garbage collection keeps reachable backing storage alive. Rust String owns a growable allocation. Assigning it to another binding moves ownership; the old binding can no…

    Go
    1package main2import "fmt"3func main() {4    first := "raven"5    second := first6    fmt.Println(first, second)7}
    Rust
    1fn announce(name: String) { println!("{}", name); }2fn main() {3    let first = String::from("raven");4    let second = first;5    announce(second);6}
  5. Strings and UTF-8

    Go strings are immutable byte sequences and may contain invalid UTF-8; ranging over a Go string decodes runes and reports replacement runes for invalid sequences. Rust String and str always contain valid UTF-8. Bytes, Unicode scalar values, and visible…

    Go
    1package main2import "fmt"3func main() {4    runes := []rune("a猫")5    for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { runes[i], runes[j] = runes[j], runes[i] }6    fmt.Println(string(runes))7}
    Rust
    1fn main() {2    let reversed: String = "a猫".chars().rev().collect();3    println!("{}", reversed);4}
  6. Option and Matching

    Go often returns a value plus a boolean to distinguish absence from a valid zero value. Rust packages those alternatives in Option<T>: Some(value) or None. It is an enum, not a nullable pointer convention, and T may itself be an integer, string, or reference.

    Go
    1package main2import "fmt"3func main() {4    scores := map[string]int{"Ada": 0}5    score, ok := scores["Ada"]6    fmt.Println(score, ok)7}
    Rust
    1fn main() {2    let values = [0, 8];3    for index in 0..3 {4        match values.get(index) {5            Some(value) => println!("value {}", value),6            None => println!("missing"),7        }8    }9}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Go developers

Learn Rust from another language

Frequently asked questions

Who is Rust for Go Developers for?

For people who already write Go and want to learn Rust. Each lesson starts from Go you know and shows how Rust does the same thing, so you skip the beginner basics.

Do I need to know Rust already?

No. The course starts with your first Rust program. You need Go basics: variables, conditions, loops, functions and collections.

How many lessons does Rust for Go Developers have?

Rust for Go Developers contains 48 interactive lessons you can complete at your own pace.

What does Rust for Go Developers cover?

The course is organized into chapters covering: First Rust Programs, Decisions and Loops, Functions and Sequences, Ownership and Borrowing, and more.

Is Rust for Go Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Rust for Go Developers for free

Get started