Skip to content

Commit e43f127

Browse files
committed
Suggestions from toasteater & used untagged repr for Variant
1 parent 172a05c commit e43f127

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
@@ -624,7 +624,7 @@ pub(super) mod serde {
624624

625625
impl Serialize for Dictionary {
626626
#[inline]
627-
fn serialize<S>(&self, ser: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
627+
fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
628628
where
629629
S: Serializer,
630630
{
@@ -645,7 +645,7 @@ pub(super) mod serde {
645645
formatter.write_str("a Dictionary")
646646
}
647647

648-
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, <A as MapAccess<'de>>::Error>
648+
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
649649
where
650650
A: MapAccess<'de>,
651651
{
@@ -657,33 +657,15 @@ pub(super) mod serde {
657657
}
658658
}
659659

660-
impl<'de> Deserialize<'de> for Dictionary<Unique> {
660+
impl<'de, Access: ThreadAccess> Deserialize<'de> for Dictionary<Access> {
661661
#[inline]
662662
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
663663
where
664664
D: Deserializer<'de>,
665665
{
666-
deserializer.deserialize_map(DictionaryVisitor)
667-
}
668-
}
669-
670-
impl<'de> Deserialize<'de> for Dictionary<Shared> {
671-
#[inline]
672-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
673-
where
674-
D: Deserializer<'de>,
675-
{
676-
Dictionary::<Unique>::deserialize(deserializer).map(Dictionary::into_shared)
677-
}
678-
}
679-
680-
impl<'de> Deserialize<'de> for Dictionary<ThreadLocal> {
681-
#[inline]
682-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
683-
where
684-
D: Deserializer<'de>,
685-
{
686-
Dictionary::<Unique>::deserialize(deserializer).map(Dictionary::into_thread_local)
666+
deserializer
667+
.deserialize_map(DictionaryVisitor)
668+
.map(|dict| unsafe { dict.cast_access() })
687669
}
688670
}
689671
}

0 commit comments

Comments
 (0)