Skip to content

Commit 2cf3851

Browse files
committed
Suggestions from toasteater & used untagged repr for Variant
1 parent f2b0d34 commit 2cf3851

File tree

3 files changed

+466
-311
lines changed

3 files changed

+466
-311
lines changed

gdnative-core/src/core_types/dictionary.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ pub(super) mod serde {
556556

557557
impl Serialize for Dictionary {
558558
#[inline]
559-
fn serialize<S>(&self, ser: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
559+
fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
560560
where
561561
S: Serializer,
562562
{
@@ -577,7 +577,7 @@ pub(super) mod serde {
577577
formatter.write_str("a Dictionary")
578578
}
579579

580-
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, <A as MapAccess<'de>>::Error>
580+
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
581581
where
582582
A: MapAccess<'de>,
583583
{
@@ -589,33 +589,15 @@ pub(super) mod serde {
589589
}
590590
}
591591

592-
impl<'de> Deserialize<'de> for Dictionary<Unique> {
592+
impl<'de, Access: ThreadAccess> Deserialize<'de> for Dictionary<Access> {
593593
#[inline]
594594
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
595595
where
596596
D: Deserializer<'de>,
597597
{
598-
deserializer.deserialize_map(DictionaryVisitor)
599-
}
600-
}
601-
602-
impl<'de> Deserialize<'de> for Dictionary<Shared> {
603-
#[inline]
604-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
605-
where
606-
D: Deserializer<'de>,
607-
{
608-
Dictionary::<Unique>::deserialize(deserializer).map(Dictionary::into_shared)
609-
}
610-
}
611-
612-
impl<'de> Deserialize<'de> for Dictionary<ThreadLocal> {
613-
#[inline]
614-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
615-
where
616-
D: Deserializer<'de>,
617-
{
618-
Dictionary::<Unique>::deserialize(deserializer).map(Dictionary::into_thread_local)
598+
deserializer
599+
.deserialize_map(DictionaryVisitor)
600+
.map(|dict| unsafe { dict.cast_access() })
619601
}
620602
}
621603
}

0 commit comments

Comments
 (0)