Re:Doing First Grade Math in Rust's Type System
by SkiFire13 on Saturday January 13, 2024 @06:31AM
(#38979050)
As others mentioned, nowadays const generics replace this technique for most problems. This technique however is still useful if you need something like `[T; A+B]` (an array whose length is the sum of two generic constants), which is not yet possible with const generics.
[ Parent
| on HN ]
Re:Doing First Grade Math in Rust's Type System
by ReleaseCandidat on Saturday January 13, 2024 @06:59AM
(#38979194)
How do you prove to the type-checker that e.g. `append(v: [T, N], w: [T, M]) -> [T, N + M]`?
Or, to make it easier, that just `append(v: [T, N], x: T]) -> [T, N + 1]`?