More in Go & Rust — page 7
Define a WebEvent enum with PageLoad, PageUnload, and KeyPress
Tests Rust enum syntax: unit versus tuple variants. A good answer defines WebEvent with PageLoad, PageUnload, and KeyPress(char), then instantiates WebEvent::KeyPress('q'). A red flag is forgetting the double colon or using struct variant syntax.
How do you append to a Go slice and why reassign?
Tests slice headers and append reallocation. A strong answer reassigns the result (s = append(s, 4)), explains that append may allocate a new backing array, and warns that ignoring the return value drops elements. Red flag: calling append without assignment.
Shadowing in Go and Rust: idioms, bugs, and if-block scoping
Tests lexical scoping in Go and Rust. Strong answers show Go's := narrowing and Rust's let rebinding, warn that Go's if := scopes across both branches, and contrast that with Rust's block-local let. Red flag: calling shadowing mutation.
Go nil pointers vs Rust Option: impact on signatures and safety
Tests encoding of absence. Go nil means any pointer may be null, pushing checks to runtime; Rust Option<T> forces compile-time handling. Strong answers cover signatures, validity, and NPO. Red flag: calling Option syntactic sugar for null.
Default integer overflow behavior in Go versus Rust
WHAT IT TESTS: Go silent wrapping vs Rust mode-based defaults. ANSWER OUTLINE: Go wraps silently; Rust panics in debug, wraps in release; Rust has wrapping_, checked_, saturating_ methods; Go needs manual checks. RED FLAG: Saying Go panics or Rust never wraps.
Describe Go slice internals and compare to Rust slice and Vec
WHAT IT TESTS: Memory layout and ownership of buffers. ANSWER OUTLINE: Go slices are three-word headers over an array; Rust &[T] is a two-word borrow without capacity; Vec<T> is an owned buffer that reallocates.

Parse a string to integer in Go and Rust with errors
This tests whether you map each language's error philosophy to syntax. Outline: Go returns (int, error) and callers check err != nil; Rust returns Result<i32, E> and callers match Ok/Err. Red flag: suggesting exceptions or ignoring Rust's must-use Result.
Compare Go string and Rust &str/String types, mutability, UTF-8, ownership
This tests your model of immutable UTF-8 strings versus owned buffers. A strong answer contrasts Go's read-only header with Rust's &str borrow and heap-owned String, noting Go immutability is structural while Rust gates mutation via ownership.
Compare Go's switch with Rust's match on exhaustiveness, fallthrough, and expressions.
Tests grasp of expression vs statement semantics and type safety. Go switch auto-breaks and lacks exhaustiveness; Rust match requires exhaustive patterns, forbids fallthrough, and yields values. Never say Go switch returns a value or Rust match falls through.
Write a 1-to-5 loop in Go and Rust
WHAT IT TESTS: idiomatic loop syntax in Go versus Rust. ANSWER OUTLINE: write Go's three-clause for, write Rust's 1..=5 range iterator, and contrast statement iteration with iterator consumption.
How does Go's variable declaration and mutability differ from Rust?
WHAT IT TESTS: Mutability defaults and syntax. ANSWER OUTLINE: Contrast Rust let (immutable) and let mut (mutable) with Go var and := (mutable), noting Go uses const for immutability. RED FLAG: Claiming Go variables are immutable or that := behaves like const.
Contrast unsafe in Go versus Rust and the invariants you assume
Tests divergent safety philosophies. Go unsafe enables FFI and pointer casting; you guarantee valid memory, alignment, and GC reachability. Rust unsafe unlocks raw pointers and FFI; you manually uphold aliasing and validity invariants behind safe APIs.
Compare Go interfaces with Rust traits
This tests structural versus nominal polymorphism and API design. A strong answer contrasts Go's implicit satisfaction with Rust's explicit impl and dyn Trait. Red flag: calling one universally better without discussing coupling or backwards compatibility.

Compare Go's GC and Rust's ownership across performance, productivity, and safety
This tests memory-model trade-offs. Contrast Rust's compile-time ownership for deterministic, zero-cost safety against Go's GC, which optimizes simplicity and onboarding but adds runtime overhead. Red flag: calling one strictly superior.
Profiling Rust with Linux perf
perf samples CPU stacks thousands of times per second to map where your Rust binary spends time without code changes. Use it on Linux to find hot functions in a slow release build. Omitting debug symbols or frame pointers gives mangled names and broken stacks.
Go Escape Analysis Chooses Stack Over Heap
Go escape analysis is the compiler pass that decides whether a variable lives on the stack or heap. It avoids heap allocations when data stays local, but any pointer that outlives its function escapes. The footgun is assuming small values never allocate.
Structs: Go's Plain Memory vs Rust's Ownership
Structs bundle named fields into a custom type. Use them when tuples or maps collapse under many values. The footgun is assuming the same syntax means the same rules: Go zero-values fields silently, while Rust demands explicit initialization unless you derive…
Primitive Scalars: Go vs Rust
Go's int grows with the architecture; Rust fixes sizes like i32 at compile time. Use Go's int for loops and Rust's i32 for counters, but both require explicit casts to mix. Assuming Go's int is 64-bit breaks 32-bit builds, and Rust's as truncates silently.
The C Application Binary Interface
An ABI is the contract a library exposes for in-process machine code access. You see this whenever a compiled program calls into a compiled library at the binary level.
FFI Error Handling: Translation and Unwinding
FFI error handling is a translation layer: foreign errors must become Rust Results before safe code sees them, or you risk UB. You do this in -sys wrappers around C libraries. The footgun: foreign exceptions unwinding across boundary without -unwind ABI is UB.