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.
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.
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.
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.
Thanks for sharing. I knew about this pattern in Rust, called typestate, but I never seen an usage to reduce code.