Hello,
I'm extremely naive about rust still and I've painted myself into a corner, so any advice on the best approach/fix for this would be welcome. It's a bit long sorry, but I got some simplified examples
Essentially my problem is I need to return an instance of a struct, but that struct is 1 of 5 possible types, but all will implement a specific trait.
My first attempt worked fine until I added the parse file method with the BufRead parameter, at this point rust complains about the trait cannot be made into an object.
After some time on Google, I found I could add a ?Sized in a few places and the new sample looks like this
The second attempt compiled and I was happy, until I try and actually use the buf, at that point I get the error the size for values of type R
cannot be known at compilation time.
Is what I'm trying to do possible? My only rational for wanting this to accept the buf is so I could potentially write a unit test for it and be able to pass in the buf for the test.