BTI Beyond The Interviews

Languages · 14 sections

Rust

Ownership, borrowing, lifetimes, and the type system — the Rust interview core.

Premium · preview 128 cards Updated 24 Oct 2026
Free to preview. The first 3 cards and the full outline are below — the rest of this sheet is part of the Languages bundle.

What's inside

Preview — first 3 of 128 cards

What are Rust's ownership rules?

Each value has exactly one owner. When the owner goes out of scope, the value is dropped (freed). Assignment and function calls move ownership for non-Copy types.

let s1 = String::from("hi");
let s2 = s1;          // move: s1 no longer valid
// println!("{}", s1); // compile error: value moved
drop(s2);             // explicit free

What is a move?

A move transfers ownership from one binding to another for any non-Copy type - including a plain struct of integers with no heap data. At runtime it is a bitwise copy of the value plus invalidation of the source; heap buffers are not copied. Moves prevent double-free without runtime cost.

#[derive(Debug)]
struct Point { x: i32, y: i32 }

let p = Point { x: 1, y: 2 };
let q = p;              // move: Point is not Copy
// println!("{p:?}");  // error: use of moved value

let v = vec![1, 2, 3];
let w = v;              // also a move: the heap buffer is not copied
println!("{q:?} {w:?}");

Which types are Copy?

Copy is for types that are safe to duplicate bitwise: every field must itself be Copy. Integers, floats, bool, char, shared references, and tuples/arrays of Copy types qualify; String, Vec and other owners do not. Assignment copies a Copy value instead of moving it.

let x = 5;
let y = x;            // Copy: both valid
println!("{x} {y}");

let s = String::from("hi");
let t = s;            // Move, not Copy
// println!("{}", s);  // error

125 more cards in this sheet

Unlock the Languages bundle — ₹399

One-time payment. Unlocks this sheet and 7 other sheets in the bundle, plus a typeset PDF of each.

Unlock the bundle See all bundles

Or get all 76 sheets for ₹999 — one payment, every future sheet included.