0

I have some struct Animal. I want to implement some methods on Vec<Animal>. I believe the correct way to do this is to create a new wrapper object called Animals. What is the correct object to make this wrapper, though? A struct? An enum? Something else?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
trexinf14s
  • 261
  • 2
  • 13
  • 1
    Take a look at this [question](https://stackoverflow.com/questions/30320083/how-to-print-a-vec) and its answer. Not a duplicate question but it seems as if it's the answer to your question. – Onorio Catenacci Mar 11 '20 at 19:58
  • @OnorioCatenacci that's actually the point of duplicates on Stack Overflow: do the *answers* of one question answer another question. – Shepmaster Mar 11 '20 at 20:06
  • Thanks, @OnorioCatenacci. It looks like I do indeed need to wrap it in a simple struct, something like `pub struct Animals(Vec)`. [This answer](https://stackoverflow.com/a/30325430/12663771) in particular was helpeful. – trexinf14s Mar 11 '20 at 20:08
  • @Shepmaster I don't think that's the point of duplicates. Questions are only duplicates if they have the same set of _potential_ answers. Otherwise we can't add new answers to the closed question that are not an answer to the "duplicate". – Sven Marnach Mar 11 '20 at 21:20
  • @SvenMarnach fair enough clarification. The text shown is “this question already has answers here”. My point is that the questions don’t have to be exact duplicates, they just have to be solved by the same answers, which is what I think you are also saying. – Shepmaster Mar 11 '20 at 21:25
  • @Shepmaster it looked a bit different to me. Thanks for the clarification! – Onorio Catenacci Mar 12 '20 at 00:59

0 Answers0