3 Comments
Apr 17Liked by Aayushya Vajpayee

What’s the benefits of using type over enum ? With an enum with two value Billed and Free you could achieved the same result and reduce binary size by preventing monomorphisation.

Expand full comment
author

I use billed_quantity and free_quantity in InvoiceLine struct. You cannot force specific enum variant in struct for these two fields but you can enforce these generic types.

Expand full comment
Apr 11Liked by Aayushya Vajpayee

Thanks for sharing. I knew about this pattern in Rust, called typestate, but I never seen an usage to reduce code.

Expand full comment