skreborn / rustic

Various constructs inspired by the Rust programming language
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Return an empty value #1

Closed SSebigo closed 3 years ago

SSebigo commented 3 years ago

Hi, I was wondering there was a built-in type representing an empty value. For example, in Dartz they have the Unit type.

I'm quite a fan of Rust and I find this approach of handling errors more elegant than Dartz one but on the other hand, having a built-in type for empty values is quite nice too instead of returning null.

tl,dr: Is there a built-in type for empty values?

skreborn commented 3 years ago

Heads up! As of May 10, 2023, the Unit type, along with the entire tuple library is going away in favor of Dart 3's built-in records.


Original answer:

Sure there is! It is indeed called Unit, and it's defined - like in Rust - as an empty Tuple.