Will Rust get pattern types?
gist.github.com·11w·
Discuss: r/rust

Summary

This RFC introduces pattern types, which are subtypes of matchable types that are statically restricted to a subset of the variants of the original type. Alongside this, this RFC also makes some changes to the Any trait to ensure that this new form of subtyping does not lead to unsoundness or breakage.

Motivation

  1. There are a number of “magic” types like NonZeroI32 and OwnedFd in core and std that expose their validity invariants (non-zero / not-minus-one) to the compiler, allowing them to have extra niche…

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