Skip to content

Instantly share code, notes, and snippets.

@xpe
Last active July 11, 2018 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpe/096ef03b9b2f41a48214f676cd9d05e3 to your computer and use it in GitHub Desktop.
Save xpe/096ef03b9b2f41a48214f676cd9d05e3 to your computer and use it in GitHub Desktop.
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