Hi! I think we all know todo!() which is nice for prototypes and design api and a lot of things...
In that loops I found my self looking something very similar, is there something like todo!() but for types? like
struct Foo {
a: u8,
b: todo!(),
c: u32,
}
fn func(a: u8, b: todo!()) -> todo!() {
let a = 10;
let b = 0.0;
todo!()
}
So, following the same logic, these are params that we still do not know which type should they use, so we use that, obvs while we use we would not be able to run any program that uses something with this type (the constructor would panic).
That options could cover part of this, is just there is some aspects from the design perspective that do not match well.
IIRC ! is when something will ends bad/panic for example, so mixing them could cause confusion because is not the actual meaning.
Run function(10, todo!()) also is not the ideal case, develop that do not implies we are not testing other types, so the todo! for types should allow to accept any input type, and still crash if something call it.
I don't know if this is possible with a macro... mmm
I was thinking even in more complex use cases, like use the macro in several places and only throw error if two functions call it with different types.
So, there is no way to write macros for parameters?
That would require the existence of a top type, which Rust does not have (that I know of, anyways).
However, todo!() evaluates to !, the bottom type, which is a subtype of every type; todo!() can be used as a value of any type, as a result - even types known to be uninhabited.
If you want your todo types to be disjoint, so that fn foo(…, a: Todo) and fn bar(…, b: Todo) refer to disjoint types, you'll need to define multiple Todo types, though. That's unavoidable one way or another; Rust has no way to instantiate a fresh type every time a name is mentioned, and a macro (of any kind) used in type position has no way to define new types, since there's no possible expansion with that characteristic.