Item Patterns and Struct Await
noratrieb.dev·1d·
Discuss: Hacker News

The Inconsistency Problem#

Quite some time ago, I wrote a blog post about the idea of struct else, which has been widely regarded as one of the most insightful pieces of Rust language design in the last few years1. If you have not read it, it’s strongly recommended to first read it.

But more recently, it has become clear that there are some serious problems around items that cause this to not work properly.

This example non-deterministically results in an error about unresolved items.

struct Test;
fn main() {
let x = Test;
}

error[E0425]: cannot find value `Test` in this scope
--> <anon>:3:13
|
3 |     let x = Test;
|             ^^^^ not found in this scope

`...

Similar Posts

Loading similar posts...