Comment

Comment by steveklabnik

? is explicitly a replacement for try!, yes.

> functions that have to return a single type

Well, all functions have to return a single type, though that type may be a composite type, like a tuple.

Less pedantically, `?` lets you (well, will let you) unwrap values and convert their error cases between each other. So once the next round of stabilization happens, if you have a function that returns Results, you can mix ? on Options and Results in the body, and vice versa. And it can be extended for other types too. Basically, it's an early return "protocol" if you will.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton