100-exercises-to-learn-rust icon indicating copy to clipboard operation
100-exercises-to-learn-rust copied to clipboard

Question: practical reason for references to integral types?

Open HeavyMetalGeek opened this issue 1 year ago • 0 comments

I just finished 03_ticket_v1 and was wondering why you would want to return a reference to an integral type? Because a reference is usize, I can understand why you wouldn't want to copy types where std::mem::size_of<T>() > std::mem::size_of<usize>. Is it just to reinforce the notion that we are returning a reference to a struct member? Or are there other practical reasons?

Also, if there is a better venue for asking these sorts of questions, I'd be happy to utilize that in the future.

Thank you for putting this together! I wish I would have had this when I started playing with Rust 3 or 4 years ago!

HeavyMetalGeek avatar May 19 '24 02:05 HeavyMetalGeek