Menu
CoddyTech
Course

Rust for TypeScript Developers

Move from TypeScript objects, unions, and array pipelines to Rust ownership, borrowing, enums, and traits. Complete 48 multi-file lessons, build a parcel depot, and port two TypeScript programs.

TypeScript and Rust side by side

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

  1. Output and Comments

    TypeScript erases type annotations and executes JavaScript; its console accepts arbitrary values. Rust compiles native code and checks formatting arguments before running. Both languages use line comments and block comments. In Rust, the exclamation mark…

    TypeScript
    1const ready: boolean = 2 < 5;2// The label is part of the output contract.3console.log(`ready=${ready}`);
    Rust
    1fn main() {2    let ready: bool = 2 < 5;3    // The label is part of the output contract.4    println!("ready={}", ready);5}
  2. Boolean Conditions

    TypeScript accepts JavaScript truthiness in conditions, so an empty string or zero can select a branch. Rust conditions require bool; a number or string is not implicitly converted. Rust comparisons return booleans and logical operators short-circuit.…

    TypeScript
    1const label = "";2const chosen = label || "fallback";3const same = chosen === "fallback";4console.log(same && !false);
    Rust
    1fn main() {2    let label = "";3    let missing = label.is_empty();4    let same = "fallback" == "fallback";5    println!("{}", missing && same);6}
  3. Functions and Returns

    TypeScript can infer a function return type and permits an explicit return. Rust function signatures specify parameter types and nonunit return types. The final expression of the body can supply the result without return; an early return remains useful for…

    TypeScript
    1function invert(value: boolean): boolean {2  return !value;3}4console.log(invert(false));
    Rust
    1fn invert(value: bool) -> bool { !value }2fn main() { println!("{}", invert(false)); }
  4. Ownership and Moves

    Assigning a TypeScript object to another variable copies a reference, so both names can access the same object. Assigning an owned Rust String transfers ownership unless you explicitly clone it. The old binding cannot be used after that move. The TypeScript…

    TypeScript
    1const original = {text: "draft"};2const alias = original;3alias.text = "ready";4console.log(original.text);
    Rust
    1fn main() {2    let original = String::from("ready");3    let owner = original;4    println!("{}", owner);5}
  5. Strings and UTF-8

    JavaScript strings expose UTF-16 code units through length and numeric indexing. Rust String and str contain UTF-8, and direct integer indexing into a string is forbidden because a byte offset might split a character. The examples iterate Unicode scalar…

    TypeScript
    1for (const scalar of "A😀") {2  console.log(scalar);3}
    Rust
    1fn main() {2    for scalar in "A😀".chars() {3        println!("{}", scalar);4    }5}
  6. Option and Matching

    TypeScript commonly represents missing values with a union containing undefined or null. Rust Option<T> makes presence a declared variant: Some carries a value and None carries none. Zero, false and empty text remain ordinary values when wrapped in Some; they…

    TypeScript
    1const samples = [0, 8];2const value: number | undefined = samples[5];3console.log(value ?? 99);
    Rust
    1fn main() {2    let samples = [0, 8];3    let value = samples.get(5);4    println!("{}", match value { Some(n) => *n, None => 99 });5}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for TypeScript developers

Learn Rust from another language

Frequently asked questions

Who is Rust for TypeScript Developers for?

For people who already write TypeScript and want to learn Rust. Each lesson starts from TypeScript 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 TypeScript basics: variables, conditions, loops, functions and collections.

How many lessons does Rust for TypeScript Developers have?

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

What does Rust for TypeScript 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 TypeScript 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 TypeScript Developers for free

Get started