Do not write APIs from training data. First determine rustc 1.y, then read the corresponding reference. Web frameworks such as Axum / Actix / Rocket are not specified in this skill.
edition is the second axis: it is only used to avoid edition-gated syntax,it cannotreplace the rustc tier.
Determine the version
- Read the locked toolchain, do not just look at
Cargo.toml'srust-version(that is the MSRV lower bound).rust-toolchain.tomlorrust-toolchain'schannel(when both files exist, per rustup:the one without a suffixrust-toolchaintakes priority)。channelisstable/beta/nightly, then runrustc --versionto get the actual1.y。
- No toolchain file: use the current
rustc --version。 - Still none: only then use
Cargo.toml'spackage.rust-version(write to that lower bound, do not use higher-tier APIs).
Get 1.y(1.97.1 → 1.97), open the table below, and write code according to that file.
| 1.y | File |
|---|---|
| 1.95 | references/1.95.md |
| 1.96 | references/1.96.md |
| 1.97 | references/1.97.md |
For newer 1.y not listed: use the highest covered tier as the base, then check RELEASES.md / blog.rust-lang.org. Older: do not use the new APIs in this skill.
When writing code, only open the current tier. 1.97 includes the 1.95/1.96 indexes that should still be used; open older tiers only when examples are needed.
edition
Read Cargo.toml 's edition(the workspace may be in [workspace.package]). When rustc is new but the edition is still 2021 , do not write syntax only enabled in 2024. When a certain edition feature is needed, first change edition, do not rely on #![feature]。
Hard rules (all hold for 1.95+)
- let chains:
if let Some(x) = a && let Ok(y) = b { }. Do not nestif let。 - For errors use
?/let else/if let. Do not treatunwrap()/expect()as control flow (allowed in tests). - Prefer std and crates already available in
Cargo.toml. Do not pull in duplicate implementations for existing functionality. - Modules, error types, and test frameworks follow the project. Do not promote web frameworks or new async runtimes in this skill.
unsafeKeep it minimal, and write SAFETY clearly right next to it.