Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pros and Cons of Wrapper Types in Rust

Pros and Cons of Wrapper Types in Rust

I've written a mathematically-oriented and computatioally-intensive application in Rust. While the mathematical theory is not necessarily difficult, keeping the various quantities clear required some care.

For this reason, I'm refactoring it to clear it up. I've created some custom structs to wrap various mathematical types.

For example, I created a type to write PDFs (probability density functions) rather than use a primitive array or vector. In my context, this feels like a good, pragmatic decision.

That said, I'm not sure how far to take the type wrapping. I'd be interested to read about other people's experience -- particularly around how they frame the tradeoffs.

If you have faced this kind of decision in in project, I would like to ask for your feedback:

  • What pros and cons did you face?
  • How did your decision work out?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.