I just tried that. It doesn't seem to work. MRE below:
struct Foo;
struct Bar;
trait Spamm {
const EGGS: u8;
}
impl Spamm for Foo {
const EGGS: u8 = 123;
}
impl Spamm for Bar {
const EGGS: u8 = 42;
}
fn frobnicate<A, B>(a: A, b: B)
where
A: Spamm,
B: Spamm<EGGS = <A as Spamm>::EGGS>,
{
todo!()
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0575]: expected associated type, found associated constant `Spamm::EGGS`
--> src/lib.rs:19:21
|
19 | B: Spamm<EGGS = <A as Spamm>::EGGS>,
| ^^^^^^^^^^^^^^^^^^ not a associated type
error: expected constant, found type
--> src/lib.rs:19:21
|
19 | B: Spamm<EGGS = <A as Spamm>::EGGS>,
| ---- ^^^^^^^^^^^^^^^^^^ unexpected type
| |
| expected a constant because of this associated constant
|
note: the associated constant is defined here
--> src/lib.rs:5:5
|
5 | const EGGS: u8;
| ^^^^^^^^^^^^^^
warning: unused variable: `a`
--> src/lib.rs:16:21
|
16 | fn frobnicate<A, B>(a: A, b: B)
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `b`
--> src/lib.rs:16:27
|
16 | fn frobnicate<A, B>(a: A, b: B)
| ^ help: if this is intentional, prefix it with an underscore: `_b`
For more information about this error, try `rustc --explain E0575`.
warning: `playground` (lib) generated 2 warnings
error: could not compile `playground` (lib) due to 2 previous errors; 2 warnings emitted