nghyane/luma / .agents/skills/numeric-casts
numeric-casts
VerifiedRules for numeric type conversions in Luma. Use when writing or reviewing code that casts between integer or float types, especially across different widths.
Numeric Casts in Luma
Widening casts (smaller → larger)
Always use From/Into, never as:
// Correct
let x: u64 = u64::from(byte);
let x: u64 = byte.into();
// Wrong — triggers clippy::cast_lossless
let x = byte as u64;
clippy::cast_lossless enforces this automatically.
Narrowing casts (larger → smaller)
Only use as when the bound is provably safe and documented:
// Acceptable — bound is clear from context
let idx = offset as usize; // offset is always < usize::MAX by construction
// Preferred when bound is not obvious
let idx = usize::try_from(offset).expect("offset fits usize");
If overflow is possible and silent truncation is wrong, use try_from and handle the error explicitly.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |