News for hackers. Stuff that matters.
Re:Weird Expressions in Rust by bobbylarrybobby on Friday June 27, 2025 @03:33PM (#44399598)
The type of return is !, not (). Meaning there are zero instances of this type (whereas there is one instance of ()). ! can coerce to any type.

Also, the type of return is a separate matter from the type of the thing being returned. You obviously can't return Result from a function returning i32. The point of type coercion is that you can yield `return Err(...)` in one branch of a match and have it type check with the other branch(es).

There are no comments on this comment yet.