nostr:npub1ykezlwa3nfn9pevwa54npu43xx49j33rgt4xjt6xqh6pxu0sjv4s8s6hgn I first saw this in ttf-parser. A trait that allows safe casting to usize that fails at compile time if target_pointer_width is too small. If you intend to only target 64-bit platforms an adaptation of it might be a nice ergonomics improvement.
I tweaked the trait/fn name to SafeFrom/safe_from when I pulled it into my own project.
https://github.com/RazrFalcon/ttf-parser/blob/e052dbb1627847cb813620637cf97ac8b6270338/src/parser.rs#L155