{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigctrcwkdjoghtof46zf43viqywdogxjtkl3hktbv4n7iwcjasbuy",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mju6yqgayhh2"
},
"path": "/t/add-something-like-num-traits-to-std-or-move-it-into-std-entirely/24181#post_10",
"publishedAt": "2026-04-19T13:41:44.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "I generally prefer to try to use standard library traits than `num_traits`; in particular, for \"numbers that support values 0 and 1\" I have taken to using `From<bool>` which is standard and works for most types you'd want it to work for.\n\nUnfortunately, this doesn't work so well with float types (but you might not want to be generic over those anyway, because float calculations generally need to be rounded and the details of the rounding frequently matter, but you can't take them into account when in a generic context).\n\nThe problem with adding extra traits is that existing number types in crates won't support them, so it tends to cause the ecosystem to become fragmented somewhat.",
"title": "Add something like `num_traits` to STD, or move it into std entirely"
}