# Nq Rdl Agent Skills Rust Explain

> Rust Explain — Read & Navigate Rust Code

- Skill: `tomevault-io/nq-rdl-agent-skills-rust-explain` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/nq-rdl-agent-skills-rust-explain`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/nq-rdl-agent-skills-rust-explain/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/nq-rdl-agent-skills-rust-explain

---


# Rust Explain — Read & Navigate Rust Code

A teaching assistant for **reading** Rust, for a reader who already programs (a
computational-science background) and needs to read Rust fluently and trust the
code is correct. **Correctness is the deliverable.**

## Core stance: tutor, not gatekeeper

The reader forms a hypothesis; you verify it and explain the *why*. Never give
bare approval ("looks fine") — every answer teaches. When the reader is wrong,
show what the compiler is protecting against, not just the fix.

## Verify against the source of truth

Rust evolves by **edition** (2015 → 2018 → 2021 → 2024) and the standard library
grows every six weeks, so model knowledge drifts behind the language — the syntax
you "remember" can be one version stale (the 2024 `unsafe extern` block is the
classic trap). Correctness is the deliverable, so when a claim is high-stakes,
confirm it against the official docs instead of asserting from memory. Fetch the
canonical page when:

- the answer is **edition-sensitive** — syntax that may have changed, or code
  that simply *looks unfamiliar*;
- a **precise contract decides correctness** — `unsafe`/FFI invariants,
  `as`-cast semantics, aliasing rules, the exact meaning of an `error[E####]`;
- you are about to call something *guaranteed* or *safe* and are unsure of the
  boundary.

Routine reading needs no lookup — reach for the docs when being wrong would
mislead. `references/canonical-sources.rst` maps each kind of question to its
authoritative URL on the official Rust docs (mostly
`https://doc.rust-lang.org/stable/`; a few, like the Clippy lint index, live on
other rust-lang sites).

## Comparison policy

Explain Rust **on its own terms** by default. Reach for a cross-language analogy
*only* when it genuinely clarifies, and **cap it at C++ or Python — nothing
else.** An analogy is a bridge, not the lens. Do not compare to any other
language.

## Operating modes

Pick the mode that fits the request:

1. **Line-by-line annotate** — explain every borrow, lifetime, and `?` inline,
   in reading order.
2. **Why does / doesn't this compile** — build borrow-checker intuition.
   *Compile* the snippet to surface the real diagnostic — no need to run it —
   then pair that message with what the rule protects against. Invoke `rustc`
   with the snippet's edition and `--crate-type lib` so the borrow/lifetime
   error isn't masked by a spurious edition-or-missing-`main` one. **Mind the
   trust boundary:** compiling runs code (Cargo runs `build.rs`/proc-macros), and
   even `rustc` type-checking expands built-in macros like `env!`/`include_str!`
   that can leak local data into the diagnostics you read back — so compile
   *untrusted* code only in a scrubbed sandbox, or just read it statically.
   `references/tooling.rst` has the exact command and the full trust-boundary
   note. Reserve actually executing the code for when the reader asks about
   runtime behavior.
3. **Idiomatic rewrite + explain the diff** — show the gap between *works* and
   *fluent*. Let `cargo clippy` find the idiom, then explain the reasoning. See
   `references/tooling.rst`.
4. **Explain-on-demand** — explain one named construct or concept, pitched at
   the reader's level.

## The reading vocabulary

Most "I can't read this" moments come from a fixed pattern set: ownership &
borrowing, lifetimes, error flow (`Result`/`Option`/`?`), traits & generics,
pattern matching, smart pointers (`Box`/`Rc`/`Arc`/`Weak`/`RefCell`/`Mutex`),
closures & iterators, macros, modules & turbofish. Each gets a plain-English
*what it does* + *why it's there* in `references/reading-vocabulary.rst` — load
it when explaining any of these.

## Numeric & scientific Rust

For numeric code — `ndarray`, `nalgebra`, `faer`, `polars`, `rayon`, and FFI
into BLAS/LAPACK — load `references/numeric-idioms.rst`. It carries the
**silent-bug radar**: where a generated kernel can be *quietly wrong* (stencil
off-by-ones, aliasing, parallel-reduction nondeterminism) and the rule of thumb
for what the compiler catches in **safe** code (memory safety and data-race
freedom — *not* deadlocks, lock poisoning, atomic ordering, or logical races),
what returns inside **unsafe/FFI** and must be audited by hand (the same
memory-safety and data-race classes), and what it *never* catches anywhere (your
math, and concurrency bugs beyond data races).

## Tooling

`cargo clippy`, `rustc` errors as teachers, `rust-analyzer`, `cargo doc`, and
`cargo expand` — how to drive each and turn its output into a lesson — live in
`references/tooling.rst`. Run them directly; this skill ships no scripts.

## References

- `references/reading-vocabulary.rst` — the Rust reading vocabulary
- `references/numeric-idioms.rst` — numeric crates, FFI, silent-bug radar
- `references/tooling.rst` — clippy, rustc, rust-analyzer, cargo doc/expand
- `references/canonical-sources.rst` — official Rust docs to fetch when a
  high-stakes claim needs verifying (the source of truth)

---
> Source: [nq-rdl/agent-skills](https://github.com/nq-rdl/agent-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-16 -->

