Skip to content

Rust Programming

Master Rust Programming with 50 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 50 cards ⏱️ ~25 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

What is Rust?

Show ▼

Rust is a systems programming language focused on safety, speed, and concurrency. It achieves memory safety without a garbage collector through its ownership system.

What is ownership in Rust?

Show ▼

Ownership is Rust's core memory management concept. Each value has exactly one owner, and when the owner goes out of scope, the value is dropped (freed). This prevents memory leaks and double frees at compile time.

What are the three ownership rules in Rust?

Show ▼

Each value in Rust has a single ownerThere can only be one owner at a timeWhen the owner goes out of scope, the value is dropped

What is borrowing in Rust?

Show ▼

Borrowing lets you reference a value without taking ownership. You create a reference with &. The original owner retains ownership while the borrower can read (or write, if mutable) the data.

What is the difference between &T and &mut T?

Show ▼

&T is an immutable reference (shared borrow) — multiple allowed simultaneously.
&mut T is a mutable reference (exclusive borrow) — only one allowed at a time, and no immutable references may coexist with it.

What is a lifetime in Rust?

Show ▼

A lifetime is a compile-time annotation (e.g., 'a) that tells the compiler how long a reference is valid. Lifetimes prevent dangling references by ensuring borrowed data outlives the borrower.

How do you annotate lifetimes on a function?

Show ▼

Use lifetime parameters in angle brackets: fn longest<'a>(x: &'a str, y: &'a str) -> &'a str. This tells the compiler the returned reference lives at least as long as the shorter of x and y.

What is the 'static lifetime?

Show ▼

'static means the reference is valid for the entire duration of the program. String literals have type &'static str because they are embedded in the binary.

What is a struct in Rust?

Show ▼

A struct is a custom data type that groups related fields. Example:
struct User { name: String, age: u32 }
Rust has three kinds: named-field structs, tuple structs, and unit structs.

How do you implement methods on a struct?

Show ▼

Use an impl block:
impl User {
  fn greet(&self) -> String {
    format!("Hi, {}", self.name)
  }
}

The first parameter is typically &self, &mut self, or self.

What is an enum in Rust?

Show ▼

An enum defines a type that can be one of several variants. Variants can hold data:
enum Shape {
  Circle(f64),
  Rectangle(f64, f64),
}

Enums are central to Rust's type system and pattern matching.

What is pattern matching in Rust?

Show ▼

Pattern matching uses match to destructure and branch on values:
match shape {
  Shape::Circle(r) => ...,
  Shape::Rectangle(w, h) => ...,
}

The compiler ensures all variants are handled (exhaustiveness).

🎓 Start studying Rust Programming

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources