Never patterns, exhaustive matching, and uninhabited types in Rust
smallcultfollowing.com
Never patterns, exhaustive matching, and uninhabited types in Rust
1–10 of 83 posts
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#2> Explicit ! patterns make it easier to define what data a match will access. They also give us a way to use lints to help bridge the needs of safe and unsafe code: we can encourage unsafe code to write explicit ! patterns where they might help document subtle points of the semantics, without imposing that burden on safe code.
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#3> if you have to define an error type for some computation, but this particular computation can never fail, you might use an uninhabited type.
I don't see the reason behind returning a Result if there is no error to return. Why not just return a String?
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#4Can someone explain why you'd want uninhabited types? > if you have to define an error type for some computation, but this particular computation can never fail, you might use an uninhabited type. I don't see the reason behind returning a Result if there is no error to return. Why not just return a String?
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#5Can someone explain why you'd want uninhabited types? > if you have to define an error type for some computation, but this particular computation can never fail, you might use an uninhabited type. I don't see the reason behind returning a Result if there is no error to return. Why not just return a String?
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#6Can someone explain why you'd want uninhabited types? > if you have to define an error type for some computation, but this particular computation can never fail, you might use an uninhabited type. I don't see the reason behind returning a Result if there is no error to return. Why not just return a String?
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#7Every time I start a new personal project I say 'oh neat I can use Rust!' N hours later (where N is a large number) I realize Go is about as fast, much easier and more readable syntax, and so I use Go if I want something that isn't Node. I'm a web developer so maybe Rust just isn't useful for that, but is Rust purely a systems level language for making super low level stuff? Forgive my ignorance, but what do people actually use it for where it outshines other languages?
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#8Alright this is going to be a dumb question but... Every time I start a new personal project I say 'oh neat I can use Rust!' N hours later (where N is a large number) I realize Go is about as fast, much easier and more readable syntax, and so I use Go if I want something that isn't Node. I'm a web developer so maybe Rust just isn't useful for that, but is Rust purely a systems level language for making super low leve…
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#9Can someone explain why you'd want uninhabited types? > if you have to define an error type for some computation, but this particular computation can never fail, you might use an uninhabited type. I don't see the reason behind returning a Result if there is no error to return. Why not just return a String?
However when returning ! the compiler can optimize the entire error handling away.
Re: Never patterns, exhaustive matching, and uninhabited types in Rust
#10Alright this is going to be a dumb question but... Every time I start a new personal project I say 'oh neat I can use Rust!' N hours later (where N is a large number) I realize Go is about as fast, much easier and more readable syntax, and so I use Go if I want something that isn't Node. I'm a web developer so maybe Rust just isn't useful for that, but is Rust purely a systems level language for making super low leve…