From 818004a19c0ef3b660451e4dd181b9978bfdec12 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 20 Sep 2023 09:35:17 -0400 Subject: [PATCH] fixup nostd build of geo-types macros --- geo-types/src/lib.rs | 2 -- geo-types/src/macros.rs | 26 ++++++++++---------------- geo-types/src/wkt_macro.rs | 1 + 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/geo-types/src/lib.rs b/geo-types/src/lib.rs index 0be76c2d5..6803cacdf 100644 --- a/geo-types/src/lib.rs +++ b/geo-types/src/lib.rs @@ -154,8 +154,6 @@ pub mod _alloc { //! Needed to access these types from `alloc` in macros when the std feature is //! disabled and the calling context is missing `extern crate alloc`. These are //! _not_ meant for public use. - - pub use ::alloc::boxed::Box; pub use ::alloc::vec; } diff --git a/geo-types/src/macros.rs b/geo-types/src/macros.rs index 491a8e73a..170d382cb 100644 --- a/geo-types/src/macros.rs +++ b/geo-types/src/macros.rs @@ -123,7 +123,7 @@ macro_rules! coord { /// [`LineString`]: ./line_string/struct.LineString.html #[macro_export] macro_rules! line_string { - () => { $crate::LineString::new(vec![]) }; + () => { $crate::LineString::new($crate::_alloc::vec![]) }; ( $(( $($tag:tt : $val:expr),* $(,)? )),* $(,)? @@ -139,11 +139,9 @@ macro_rules! line_string { $(,)? ) => { $crate::LineString::new( - <[_]>::into_vec( - $crate::_alloc::Box::new( - [$($coord), *] - ) - ) + $crate::_alloc::vec![ + $($coord),* + ] ) }; } @@ -216,7 +214,7 @@ macro_rules! line_string { /// [`Polygon`]: ./struct.Polygon.html #[macro_export] macro_rules! polygon { - () => { $crate::Polygon::new($crate::line_string![], vec![]) }; + () => { $crate::Polygon::new($crate::line_string![], $crate::_alloc::vec![]) }; ( exterior: [ $(( $($exterior_tag:tt : $exterior_val:expr),* $(,)? )),* @@ -262,15 +260,11 @@ macro_rules! polygon { $crate::line_string![ $($exterior_coord), * ], - <[_]>::into_vec( - $crate::_alloc::Box::new( - [ - $( - $crate::line_string![$($interior_coord),*] - ), * - ] - ) - ) + $crate::_alloc::vec![ + $( + $crate::line_string![$($interior_coord),*] + ), * + ] ) }; ( diff --git a/geo-types/src/wkt_macro.rs b/geo-types/src/wkt_macro.rs index 9c625e817..df39e2667 100644 --- a/geo-types/src/wkt_macro.rs +++ b/geo-types/src/wkt_macro.rs @@ -141,6 +141,7 @@ macro_rules! wkt_internal { #[cfg(test)] mod test { use crate::geometry::*; + use alloc::vec; #[test] fn point() {