소스 검색

fix issue 1586 followup (#2733)

Adam Kundrát 11 달 전
부모
커밋
a1dfc4b4f0
2개의 변경된 파일1개의 추가작업 그리고 17개의 파일을 삭제
  1. 0 16
      packages/core/src/hotreload_utils.rs
  2. 1 1
      packages/core/src/nodes.rs

+ 0 - 16
packages/core/src/hotreload_utils.rs

@@ -71,19 +71,3 @@ pub enum FmtSegment {
         id: usize,
         id: usize,
     },
     },
 }
 }
-
-/// A helper function for deserializing to a `&'static str`.
-/// Parses escaped characters (like `"\n"` or `"\t"`),
-/// which cannot be done in-place using the default serde json deserializer.
-///
-/// **Leaks the memory** in order to achieve a `'static` reference.
-///
-/// Solves [this issue](https://github.com/DioxusLabs/dioxus/issues/1586).
-#[doc(hidden)]
-pub fn static_str_deserializer<'de, D>(deserializer: D) -> Result<&'static str, D::Error>
-where
-    D: serde::de::Deserializer<'de>,
-{
-    <String as serde::Deserialize>::deserialize(deserializer)
-        .map(|s| Box::leak(Box::new(s)) as &'static str)
-}

+ 1 - 1
packages/core/src/nodes.rs

@@ -523,7 +523,7 @@ pub enum TemplateNode {
     /// This template node is just a piece of static text
     /// This template node is just a piece of static text
     Text {
     Text {
         /// The actual text
         /// The actual text
-        #[serde(deserialize_with = "crate::hotreload_utils::static_str_deserializer")]
+        #[serde(deserialize_with = "deserialize_string_leaky")]
         text: &'static str,
         text: &'static str,
     },
     },