I am trying to use a common data type where one of the types is not needed (the weight of the borders in the graph). I thought to use this type never, which would look something like this:
#![feature(never_type)]
struct Foo<T> {
bar: T
}
impl<T> Foo<T> {
fn foo(&mut self, bar: T) {
self.bar = bar;
}
}
fn main() {
let mut foo: Foo<!> = Foo { bar: "nada" };
foo.foo("nada");
}
This obviously leads to type mismatch for placeholders "nada", but just typing nothing will lead to other errors. Is the !correct type to use here, and if so, what is the correct syntax?
I used it using ()instead !, but I'm a little unsure of the correct type selection. I believe that from the point of view of efficiency, it should not make any difference, since ()it has no trace of memory?
source
share