Compiling playground v0.0.1 (/playground)
error[E0599]: the function or associated item `new` exists for struct `Foo<0_i32>`, but its trait bounds were not satisfied
--> src/main.rs:17:23
|
4 | pub struct Foo<const I: i32> {}
| ---------------------------- function or associated item `new` not found for this
...
17 | let b = Foo::<0>::new();
| ^^^ function or associated item cannot be called on `Foo<0_i32>` due to unsatisfied trait bounds
...
20 | struct Boolean<const B: bool>;
| ------------------------------ doesn't satisfy `Boolean<{ is_zero(I) }>: Marker`
|
= note: the following trait bounds were not satisfied:
`Boolean<{ is_zero(I) }>: Marker`
note: the following trait must be implemented
--> src/main.rs:26:1
|
26 | trait Marker {}
| ^^^^^^^^^^^^^^^
error[E0599]: no function or associated item named `some_function_only_exists_in_I_eq_0` found for struct `Foo<1_i32>` in the current scope
--> src/main.rs:15:15
|
1 | struct Foo<const I: i32> {}
| ------------------------ function or associated item `some_function_only_exists_in_I_eq_0` not found for this
...
15 | Foo::<1>::some_function_only_exists_in_I_eq_0();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Foo<1_i32>`
|
= note: the function or associated item was found for
- `Foo<0_i32>`
Hi, it looks that the playground report a totally different error, so do my compiler, is there any doc talks about this { is_zero(I)} feature, I somehow understand what you are trying to do.
If you want to use const expressions (i.e. call is_zero() with the I const) then you need to wrap it in curly braces so it doesn't get parsed as a type. Evaluating const expressions in generics is still very incomplete, so your best bet is to check the PR or RFC associated with generic_const_exprs.