Best practices for ID newtypes ergonomics in domain models

Best practices for ID newtypes ergonomics in domain models
i haven't used this that often but personally when i have a lot of types with similar behaviours and different semantic tags i like to use phantomdata for example you could have struct ID{ value:usize tag:PhantomData } then defining tags becomes quick and painless or you can even reuse other types as tags if it makes sense. struct User{ id:ID, ... } depending on your project you might even do generic functions over them

Take Your Experience to the Next Level

New

Download our mobile app for a faster and better experience.

Comments

0
U

Join the discussion

Sign in to leave a comment

0:000:00