I’m writing a CBOR library with two main data types:
Cbor<'a> is a wrapper around a
&'a [u8] while
CborOwned is a wrapper around
SmallVec<[u8; 16]>. The wrappers assert that the wrapped bytes are actually valid CBOR.
It would be nice if I could
impl<'a> ToOwned for Cbor<'a> but I can’t, and the reason seems incidental — the required
impl Borrow for CborOwned can’t be written because I can’t return a reference to a local value (CborOwned doesn’t contain a Cbor that I could borrow).
Now before I embark on the journey of making a library with an improved ToOwned/Borrow combo, perhaps there are reasons for the choice in
borrow()’s signature, which is why I ask here. Thanks in advance for any answers!