Open jamesmunns opened 1 year ago
Would it be worth adding a reworked Interner
flavor from that gist you made to postcard
proper in the future?
(I didn't get to work on tailoring it to my needs today, sorry!)
Yeah, I think it could make sense. It might be reusable by this and the IO stuff.
Not sure yet though, I need to actually do a more in depth look at pr91 first, to see if that matches what they were doing.
Right now, we don't really distinguish between cases where we want to take N bytes from the stream because we might want to borrow the data (e.g. for zero-copy
&'de str
or&'de [u8]
cases), and where we just happen to know we want the next N bytes in the stream (e.g. the current deserializers forf32
,f64
, andchar
).While discussing an "interning flavor" with @cr1901, I realized that the approach I took in this proof of concept would inadvertently intern bytes for the f32/f64/char types as well, even though these only need to be "transient" borrows.
It might be worth it to add a new default trait method, like
try_take_n_transient
, which defaults to passing through totry_take_n
, to allow flavors that care to distinguish between these kinds oftakes
.Could be relevant to #91.