SuperAPI AI Directory

rust

Coding & development

View repository

Updated 10-16 07:24

About this skill

Rust

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

  1. Read the locked toolchain, do not just look at Cargo.toml 's rust-version(that is the MSRV lower bound).
    • rust-toolchain.toml or rust-toolchain 's channel(when both files exist, per rustup:the one without a suffix rust-toolchain takes priority)。
    • channel is stable / beta / nightly , then run rustc --version to get the actual 1.y。
  2. No toolchain file: use the current rustc --version。
  3. Still none: only then use Cargo.toml 's package.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 nest if let。
  • For errors use ? / let else / if let. Do not treat unwrap() / 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.
  • unsafe Keep it minimal, and write SAFETY clearly right next to it.