You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vision/why-compile-time-evaluation.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,11 @@ prevents the input for that computation to simply be a generic or function param
15
15
16
16
## Why const generics?
17
17
18
-
In most cases, const evaluation by itself is good enough, so const generics isn't needed. An exception to this is
19
-
if the value should influence the type system.
18
+
Const evaluation by itself is good enough unless it should influence the type system.
20
19
21
-
This is needed when influencing the layout of types, most often by using arrays.
22
-
Using arrays instead of dynamic allocations or slices can improve the performance, reduces the dynamic memory footprint
23
-
and can remove the runtime checks and implicit invariants.
20
+
This is needed when computing the layout of types, most often by using arrays.
21
+
Using arrays instead of dynamic allocations or slices can improve performance, reduces the dynamic memory footprint
22
+
and can remove runtime checks and implicit invariants.
24
23
25
24
Another reason is to be generic over configurations or to move certain conditions to compile time. Consider [image handles](https://github.com/EmbarkStudios/rust-gpu/blob/1431c18b9db70feafc64e5096a64e5fefffbed18/crates/spirv-std/src/image.rs#L31) in [`rust-gpu`](https://github.com/EmbarkStudios/rust-gpu) or TODO: example for state machines.
0 commit comments