Item Patterns and Struct Await
noratrieb.dev·17w·
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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help