Reputation: 1253
I want to leave an associated type specification in a trait implementation for later, as it requires some work. Is there any way I can tell the compiler to ignore the missing associated type?
impl A for B {
type C = todo()!;
}
It throws this error
error: non-type macro in type position: ::core::panic
Upvotes: 0
Views: 130
Reputation: 426
Rust macros like todo!()
aren't magic, they must expand to valid Rust code. In the case of todo()
it expands to panic!("not yet implemented: ....")
(see src).
If you use a macro in a type, then it must expand to a valid type. Unfortunately, that means you can't have it expand to the equivalent of todo!()
: it wouldn't really make sense!
However, instead, you can use ()
as a placeholder, or even define a custom type alias: type Todo = ()
.
Upvotes: 0