Skip to content

Commit 5389636

Browse files
committed
serde: Add GcDeserializeOwned
1 parent 50d834b commit 5389636

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/serde.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ pub trait GcDeserialize<'gc, 'de, Id: CollectorId>: GcSafe<'gc, Id> + Sized {
3535
fn deserialize_gc<D: Deserializer<'de>>(ctx: &'gc Id::Context, deserializer: D) -> Result<Self, D::Error>;
3636
}
3737

38+
/// A garbage collected type that can be deserialized without borrowing any data.
39+
///
40+
/// [GcDeserialize] is to [`serde::de::Deserialize`]
41+
/// as [GcDeserializeOwned] is to [`serde::de::DeserializeOwned`]
42+
pub trait GcDeserializeOwned<'gc, Id: CollectorId>: for<'de> GcDeserialize<'gc, 'de, Id> {}
43+
impl<'gc, Id, T> GcDeserializeOwned<'gc, Id> for T
44+
where Id: CollectorId, T: for<'de> GcDeserialize<'gc, 'de, Id> {}
45+
3846
impl<'gc, 'de, Id: CollectorId, T: GcDeserialize<'gc, 'de, Id>> GcDeserialize<'gc, 'de, Id> for Gc<'gc, T, Id>
3947
where Id::Context: GcSimpleAlloc {
4048
#[inline]

0 commit comments

Comments
 (0)