Rust Send and Sync marker traits explained
WHAT IT TESTS: understanding of compile-time thread-safety guarantees. OUTLINE: Send means a value can move across threads, Sync means a reference can be shared; Rc uses non-atomic refcounts, Arc uses atomic ones. RED FLAG: confusing the two traits.
Using context.Context across microservice calls in Go
WHAT IT TESTS: request-scoped context propagation. OUTLINE: context carries cancellation, deadlines, and values; pass ctx as first arg, set one WithTimeout at the edge, attach a request ID via WithValue, thread it through downstream calls so all cancel…
Static dispatch over Write with generics in Rust
WHAT IT TESTS: static vs dynamic dispatch trade-offs. OUTLINE: write generically over the std::io::Write trait with a type parameter W: Write, letting the compiler monomorphize and inline per concrete type, avoiding the vtable indirection of Box<dyn Write>.
Logging middleware wrapping an http.Handler in Go
WHAT IT TESTS: the http.Handler middleware pattern. OUTLINE: middleware has signature func(http.Handler) http.Handler, records start time, calls next.ServeHTTP, then logs method, URL, and elapsed duration; chaining works because the wrapper is itself a…
In-memory rate limiter middleware in Go
WHAT IT TESTS: rate limiting and middleware design. OUTLINE: use a token-bucket limiter (golang.org/x/time/rate), guard a per-client map with sync.Mutex, wrap http.Handler so requests over the limit get 429.
Handling Result and errors in a Rust web handler
WHAT IT TESTS: Result-based error handling in web handlers. OUTLINE: handler returns Result, the ? operator early-returns errors, a custom error type implements IntoResponse to map to 500, success returns 200 with data.
Structuring a Go CLI that fetches a URL
WHAT IT TESTS: basic Go CLI, HTTP, and error handling. OUTLINE: parse args with the flag package, http.Get the URL, check err and status, defer resp.Body.Close, copy body to stdout, exit non-zero on failure.
cgo directives: CFLAGS, LDFLAGS, and pkg-config
WHAT IT TESTS: cgo build configuration. OUTLINE: #cgo CFLAGS feeds the C compiler include paths/defines, LDFLAGS feeds the linker libraries/paths, pkg-config auto-discovers both; needed to compile against a system C library.
Building a safe Rust wrapper over an unsafe C API
WHAT IT TESTS: FFI encapsulation patterns. OUTLINE: hide extern calls behind a safe module, own the resource in a struct with Drop calling the C free, return Result mapping C error codes, use NewType/NonNull and PhantomData.
Passing Go/Rust callbacks to a C library
WHAT IT TESTS: FFI callback mechanics. OUTLINE: C needs a plain function pointer; in Go use //export with cgo, in Rust an extern "C" fn; carry state via a void* user-data param.
Zero-copy string to []byte conversion via unsafe in Go
WHAT IT TESTS: Go memory layout and unsafe trade-offs. OUTLINE: use unsafe.StringData/Slice (or reflect headers) to alias the string's bytes without copying; assumes shared backing array; risk is mutating an immutable string.
Rust references vs raw pointers
WHAT IT TESTS: safety invariants of references. OUTLINE: references are borrow-checked, always valid, aliasing-controlled, non-null; raw pointers carry no guarantees, can be null, dangling, or aliased, and dereferencing needs unsafe.
Profiling a Rust hot loop with perf
WHAT IT TESTS: low-level performance profiling. OUTLINE: build with debuginfo, perf record cycles or cache-misses, perf report then perf annotate to map counters to source/asm; flamegraph for hotspots.
Diagnosing Go memory leaks with pprof heap profiles
WHAT IT TESTS: production profiling with pprof. OUTLINE: expose net/http/pprof, grab /debug/pprof/heap, analyze inuse_space for live retention versus alloc_space for cumulative allocation; rising inuse over time points to a leak.
Cancellation: Go context vs Rust sync stdlib
WHAT IT TESTS: cancellation propagation models. OUTLINE: Go's context.Context threads a Done channel and deadline through call chains; Rust std has no built-in cancellation, so you wire an AtomicBool or channel and check it.
Network read/write timeouts in Go vs Rust stdlib
WHAT IT TESTS: stdlib IO timeout APIs and design philosophy. OUTLINE: Go uses SetReadDeadline/SetWriteDeadline as absolute times; Rust uses set_read_timeout/set_write_timeout as durations on TcpStream.
Concurrent TCP server: Go goroutines vs Rust std::thread
WHAT IT TESTS: stdlib networking and concurrency. OUTLINE: both accept in a loop; Go spawns a goroutine per connection (go handle(conn)); Rust spawns an OS thread (thread::spawn moving the stream).
Purpose and mechanism of a Rust build.rs script
WHAT IT TESTS: Cargo's build pipeline. OUTLINE: build.rs compiles and runs before the crate, emitting cargo: directives via stdout to set link flags, env vars, and rerun triggers; used to compile C, generate code, or probe the system.
Rust async/await vs Go goroutines
WHAT IT TESTS: async execution models. OUTLINE: Go schedules goroutines on a built-in runtime transparently; Rust futures are inert until polled by an external runtime like Tokio, and async colors functions.
Sharing mutable state: Go mutex vs Rust Arc Mutex
WHAT IT TESTS: shared-state concurrency and compile-time safety. OUTLINE: Go uses sync.Mutex by convention; Rust wraps data in Arc<Mutex<T>> so locking is mandatory, enforced by Send/Sync and the borrow checker.