5
lorentz
1y

Vec<()> can be used as an unsigned integer

Comments
  • 0
    @kobenz no idea but it doesn't allocate so it can't be that bad.
  • 1
    @lorentz
    You are the reason we can't have nice things.
  • 0
    @ostream this happens to be Rust, but it should work in every language with zero-size types, so most statically typed languages.
  • 1
    @ostream A lot of people say that zero-sized types are silly, but IMO assigning a positive size to a non-polymorphic enum with only one variant is much sillier.
  • 1
    @ostream Types with only one possible value are universal. The absence of zero-sized types is a failure of the optimizer.
  • 2
    @ostream Types are also universal, some languages just help you keep track of them while in others you have to remember them or keep the manually verified annotations up to date.
Add Comment