Get the latest tech news

Weird Expressions in Rust


Explore weird quirks of rusts type system

Note that these are not bugs, but rather extreme cases of rust features like loops, expressions, coercion and so on. In the first line we immediately exit the loop, because break is a valid expression, which has the type!, we can use it in an if statement. Then we immediately call that closure, passing in a tuple with a string and a char, and an empty block.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of Weird Expressions

Weird Expressions

Related news:

News photo

Why is the Rust compiler so slow?

News photo

Rust 1.88 Released With Improvements For Naked Functions, Chaining Let Statements

News photo

Microsoft Edit