2 ms·
> Prior to this change most Rust developers would never have cause to ever use `!` for any reason. As a type. "!" is in the most basic example nearly every ru
by ketzu 21d ago
> Prior to this change most Rust developers would never have cause to ever use `!` for any reason.
As a type.
"!" is in the most basic example nearly every rust developer has seen:
println!("Hello, World!");
Unless you specifically watched a presentation or read a blog post about the never type, you probably haven't seen it as a type.
If the average (and nearly all new) rust developers encounters "fn bla(blub: i64) -> !" I suspect they will mostly go "huh??" (or wonder what kind of weird macro that is) until it becomes common to encounter early and gets it's own early entry in the rust book.
Compared to reading "fn blub(bla: &str) -> Never", which seems rather straight forward imo. However, "Never" might be the name of some actual Struct or Enum in various codebases.
- simonask 21d agoWell, one thing that every Rust programmer knows is the `panic!(...)` macro, and its return type is "!". That's why this compiles, even though not even match arm produces a value, which I think many Rust programmers are familiar with: let b = match a { 0 => 123, 2 => panic!("mustn't be two"), _ => todo!(), }; Other expression that are evaluated as having the type "!": return, break, continue.