Codex Luma Rust Numeric Casts for Narrowing Errors
Match Luma's conversion rules for lossless widening and potentially overflowing Rust narrowing.
中文Install in Codex
Open Luma in Codex with the source and target types and any range constraints you can establish.
- Review `.agents/skills/numeric-casts/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.agents/skills/numeric-casts/` in your project and save the reviewed file as `.agents/skills/numeric-casts/SKILL.md`.
- Start Codex from that project's root, then type `$numeric-casts` and select the matching skill.
Example task
Review how to store this offset in a narrower field.
{"from":"u64","to":"u16","offset":70000,"knownUpperBound":false}What to check
Use `u16::try_from(70000_u64)` and handle `Err`. The value 70000 cannot be represented as a `u16`.
Original SKILL.md on GitHub · Updated
Frequently asked question
How should I widen a u8 into a u64?
Use u64::from or Into with a u64 target type. This widening preserves the original value.