this post was submitted on 28 Mar 2024
247 points (94.3% liked)
Rust
6035 readers
2 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Absolutely! Types are as much about providing the programmer with information as they are the compiler. A well typed and designed API conveys so much useful information. It's why it's mildly infuriating when I see functions that look like something from C where you'll see like:
rather than a better strongly typed version like:
I disagree with this, I don't think those are ever necessary assuming a powerful enough type system. Function arguments should always have a defined type, even if it's using dynamic dispatch. If you just want to not have to specify the type on a local,
let
bindings where you don't explicitly define the type are fine, but even in that case it still has a type, you're just letting the compiler derive it for you (and if it can't it will error).