From 5ccc1ffbc409ab3193aa67c23efcfa897f6033b9 Mon Sep 17 00:00:00 2001 From: dragonn Date: Fri, 8 Dec 2023 10:30:47 +0100 Subject: [PATCH] add alloc feature to serde_at --- serde_at/Cargo.toml | 1 + serde_at/src/de/mod.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/serde_at/Cargo.toml b/serde_at/Cargo.toml index 514c49a..23c00f8 100644 --- a/serde_at/Cargo.toml +++ b/serde_at/Cargo.toml @@ -29,3 +29,4 @@ default = [] custom-error-messages = [] std = [] hex_str_arrays = [] +alloc = ["serde/alloc"] diff --git a/serde_at/src/de/mod.rs b/serde_at/src/de/mod.rs index bbbee43..82d21ae 100644 --- a/serde_at/src/de/mod.rs +++ b/serde_at/src/de/mod.rs @@ -483,12 +483,19 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Deserializer<'de> { } } - /// Unsupported. String is not available in no-std. + /// Supported only if alloc feature is enabled fn deserialize_string(self, _visitor: V) -> Result where V: Visitor<'de>, { - unreachable!() + #[cfg(feature = "alloc")] + { + self.deserialize_str(_visitor) + } + #[cfg(not(feature = "alloc"))] + { + unreachable!() + } } fn deserialize_bytes(self, visitor: V) -> Result