I very much like the originally proposed version.
Comparing
let? Ok(user) = await fetchUser(id)
let? Ok(decodedUser) = decodeUser(user)
let? Ok() = await ensureUserActive(decodedUser)
let someThingElse = ...
to something like
let Ok(user) ?= await fetchUser(id)
let Ok(decodedUser) ?= decodeUser(user)
let Ok() ?= await ensureUserActive(decodedUser)
let someThingElse = ...
I find that
- In the first version, when reading the code, I can see at the very first glance which lets are “normal” lets and which are not, without having to scan further to the right.
- In the first version, the
?are neatly stacked below each other. (And I think it will be a very frequent use case to have multiple lines withlet?“stacked” like in the example.)
I also think that the ? is a good choice compared to other characters as it is familiar for dealing with options (optional chaining) in TypeScript.