All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
4330 bites
Page 128
Write a 1-to-5 loop in Go and Rust
Write Go's three-clause for, write Rust's 1..=5 range iterator, and contrast statement iteration with iterator consumption.
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.
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.

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.
Describe Go slice internals and compare to Rust slice and Vec
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.
Default integer overflow behavior in Go versus Rust
Go wraps silently; Rust panics in debug, wraps in release; Rust has wrapping_, checked_, saturating_ methods; Go needs manual checks.
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.
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.
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.
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.
Define a User struct and map of IDs to pointers
Tests Go struct and map pointer basics. Outline: define User with ID and Name, initialize map[int]*User with make, insert &User literals, and note shared mutation. Red flag: writing to a nil map or storing values instead of pointers.
How do you safely share a Go map across goroutines?
Tests Go memory model. Answer: maps are not concurrency-safe and risk panic or corruption; use sync.RWMutex with map for read-heavy cases or sync.Map for cache-like patterns. Red flag: suggesting runtime.GOMAXPROCS or channel-only access without justification.
What type replaces String for read-only function parameters in Rust?
Use &str; it borrows without ownership, accepts literals and String via coercion, and avoids clones.
Sum Some values in Vec<Option<i32>>, ignoring None
Tests Rust Option handling and null-safety design. A strong answer uses map, unwrap_or, flatten, or match to skip Nones safely, and explains Option replaces null pointers with explicit enum variants. Red flag: using unwrap in a loop or suggesting null checks.
Explain Go struct embedding vs inheritance and method promotion
What it tests: knowing Go composition and method promotion from embeds. Outline: embedding adds a type as part without is-a; promoted methods join the outer type; collisions resolve by outer-type precedence.
How does struct field ordering affect memory layout in Go and Rust?
It tests alignment, padding, and compiler layout knowledge. A strong answer explains that alignment inserts padding, Go and Rust keep declared order, and reordering by size can shrink size. Red flag: saying order is irrelevant or that compiler auto-packs.
Compare enum vs trait objects for heterogeneous shapes in Rust
This tests compile-time vs run-time polymorphism in Rust. A strong answer contrasts enum's closed set, static dispatch, and stack layout against trait objects' open extensibility, heap allocation, and vtable indirection.
How do Go and Rust control visibility of functions and types?
Tests encapsulation conventions in systems languages. Go uses capitalization: uppercase exports across packages; Rust uses explicit pub keywords with module-level privacy. Red flag: claiming either uses Java-style access modifiers or runtime visibility.
Go package declaration, directory name, and import path relationship
Tests Go's separation of directory layout and package identity. A good answer states: import path is module path plus subdirectory; package clause is the in-code name; mismatch is legal and common for main or tests.

Why does Go forbid circular dependencies, and how do you resolve them?
Cycles break incremental compilation; resolve by moving logic down, merging coupled packages, or using dependency injection.