Skip to content

Commit e930052

Browse files
committed
Fixed #707
implemented `Decode` and `BorrowDecode` for Rc<str>
1 parent b5fbbf9 commit e930052

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
*.swo
55
.cargo
66
.vscode
7+
.idea
78
rls*.log
89
tarpaulin-report.html

src/features/impl_alloc.rs

+14
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ where
451451
}
452452
}
453453

454+
impl Decode for Rc<str> {
455+
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
456+
let decoded = String::decode(decoder)?;
457+
Ok(decoded.into())
458+
}
459+
}
460+
454461
impl<'de, T> BorrowDecode<'de> for Rc<T>
455462
where
456463
T: BorrowDecode<'de>,
@@ -461,6 +468,13 @@ where
461468
}
462469
}
463470

471+
impl<'de> BorrowDecode<'de> for Rc<str> {
472+
fn borrow_decode<D: BorrowDecoder<'de>>(decoder: &mut D) -> Result<Self, DecodeError> {
473+
let decoded = String::decode(decoder)?;
474+
Ok(decoded.into())
475+
}
476+
}
477+
464478
impl<T> Encode for Rc<T>
465479
where
466480
T: Encode + ?Sized,

0 commit comments

Comments
 (0)