Skip to content

Commit

Permalink
Implement Decode for Box<str> (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaJewson authored Jul 23, 2022
1 parent 1ca8275 commit 3a4f299
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/features/impl_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ impl Decode for String {
}
impl_borrow_decode!(String);

impl Decode for Box<str> {
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
String::decode(decoder).map(String::into_boxed_str)
}
}
impl_borrow_decode!(Box<str>);

impl Encode for String {
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
self.as_bytes().encode(encoder)
Expand Down

0 comments on commit 3a4f299

Please sign in to comment.