You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a function that encodes an input Into<Cow<'static, [u8]>>. When there is encoding accepted I return a new Cow::Owned. But when there is no encoding accepted I just return the input. Here is what it looks like
Then I have to convert this value into Bytes. For now I can either use match (which becomes too much boilerplate) or Cow::into_owned to convert to Vec<u8> and then Bytes (but that will convert any &'static [u8] to a Vec and thus allocate). I was wondering whether it would be possible to implement From<Cow<'static, [u8]>> for Bytes. From what I can see From<&'static [u8]> and From<Vec<u8>> are already implemented so I don't see an issue.
The text was updated successfully, but these errors were encountered:
I have a function that encodes an input
Into<Cow<'static, [u8]>>
. When there is encoding accepted I return a newCow::Owned
. But when there is no encoding accepted I just return the input. Here is what it looks likeThen I have to convert this value into
Bytes
. For now I can either usematch
(which becomes too much boilerplate) orCow::into_owned
to convert toVec<u8>
and thenBytes
(but that will convert any&'static [u8]
to aVec
and thus allocate). I was wondering whether it would be possible to implementFrom<Cow<'static, [u8]>>
forBytes
. From what I can seeFrom<&'static [u8]>
andFrom<Vec<u8>>
are already implemented so I don't see an issue.The text was updated successfully, but these errors were encountered: