Codex Rust Const Generics for Fixed-Size Buffers
Represent an array length in its type and verify that callers observe the intended size contract.
中文Install in Codex
Codex, a Rust project and Cargo toolchain. The example uses small safe arrays.
- Copy the pinned `skills/rust-const/` directory into `.agents/skills/rust-const/` in the project.
- Select `$rust-const` and identify the length invariant for the change.
Example task
In a practice crate, model buffers for four or eight item identifiers. Test a function that accepts only the four-item buffer.What to check
The sizes are visible in the types, and the compile check rejects an eight-item buffer at the four-item call site.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should every collection use const generics?
Use a compile-time size when it is part of the contract. Keep runtime sizes dynamic.