{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreidaxklayyto5v3mjnzafnaatfaqv6ynev6e7erudamax5wkfdipwi",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjrfpnl4u4f2"
},
"path": "/t/add-something-like-num-traits-to-std-or-move-it-into-std-entirely/24181#post_1",
"publishedAt": "2026-04-18T10:22:13.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"@CodesInChaos",
"this comment"
],
"textContent": "For generic number implementations in `std::num`, as @CodesInChaos pointed out in this comment for the case of complex numbers, `num_traits` would make implementations significantly more flexible, and (in my opinion) much easier. For example, it would be much easier to implement a (hypothetical) complex sine function just like this:\n\n\n impl<T: Float> Complex<T> {\n fn sin(self) {\n Complex::new(sin(self.re) * cosh(self.im), cos(self.re) + sinh(self.im)\n }\n }\n\n\ninstead of expanding over multiple implementations. Also, if this were made public, it would allow people to write their own implementation of `Float` and use `std` types with their definition of `Float` (for their own purposes).\n\nA similar type already exists (`core::simd::num::SimdFloat`), which could be considered prior art.",
"title": "Add something like `num_traits` to STD, or move it into std entirely"
}