From e713ed5d587ce49ff5cb112f8e0a9c70c23bbed4 Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Tue, 19 Nov 2024 10:20:01 +0100 Subject: [PATCH] tostatic: fix build with nostd --- src/tostatic.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/tostatic.rs b/src/tostatic.rs index 5df6c97..e6e1eb0 100644 --- a/src/tostatic.rs +++ b/src/tostatic.rs @@ -49,8 +49,6 @@ macro_rules! impl_tostatic_primitive { impl_tostatic_primitive!(bool); impl_tostatic_primitive!(I i8 i16 i32 i64 i128 isize); impl_tostatic_primitive!(I u8 u16 u32 u64 u128 usize); -impl_tostatic_primitive!(I String); -impl_tostatic_primitive!(str => String, |s| s.to_string()); impl ToStatic for &'_ T where @@ -63,17 +61,6 @@ where } } -impl ToStatic for Box -where - T: ToStatic, -{ - type Owned = Box; - - fn to_static(&self) -> Self::Owned { - Box::new(self.as_ref().to_static()) - } -} - impl ToStatic for Option where T: ToStatic, @@ -84,3 +71,20 @@ where self.as_ref().map(ToStatic::to_static) } } + +#[cfg(feature = "std")] +const _: () = { + impl_tostatic_primitive!(I String); + impl_tostatic_primitive!(str => String, |s| s.to_string()); + + impl ToStatic for Box + where + T: ToStatic, + { + type Owned = Box; + + fn to_static(&self) -> Self::Owned { + Box::new(self.as_ref().to_static()) + } + } +};