logoalt Hacker News

etyplast Friday at 9:23 PM1 replyview on HN

This is one of those natural consequences of "everything is an expression" languages that I really like! I like more explicit syntax like Zig's labelled blocks, but any of these are cool.

Try this out, you can actually (technically) assign a variable to `continue` like:

let x = continue;

Funnily enough, one of the few things that are definitely always a statement are `let` statements! Except, you also have `let` expressions, which are technically different, so I guess that's not really a difference at all.


Replies

tialaramexyesterday at 2:21 PM

I'm not sure why you picked continue here? All the diverging control flow instructions have the same type, ! aka "Never". In stable Rust you're not allowed to use its name but it's "just" an empty type and you can easily make one of those yourself - an enum with no variants.