Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSliceBox: allow Deref into &[T] #40
Conversation
Allows more convenient use of SliceBox where one doesn't care whether it represents a Vec<T> or &[T] and can handle using a &[T].
|
How are you using this in your code? The reason that I didn't add this impl is because slicebox should be used only for immediate encoding / decoding and shouldn't really be used outside of that, so there shouldn't be a case where you aren't 100% certain that it represents a Vec or &[T]. |
|
I'm using structs I encode/decode directly for things in my programs other than encoding and decoding. Note that there is already a (nearly identical) implementation of Deref for RefBox (which this code was based on) which, as far as I can see, is provided for similar uses. I suppose what I'm getting at is that I didn't have a reason to force something to be a Vec instead of a &[u8], and adding this makes it possible (well, at least decreases the code overhead) of sharing functions that handle the encoded/decoded structs between sides of the encode/decode. |
SliceBox: allow Deref into &[T]
|
Fair enough; thanks for the pull request! |
jmesmon commentedMay 28, 2015
Allows more convenient use of SliceBox where one doesn't care whether
it represents a Vec or &[T] and can handle using a &[T].