-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wkt macro to create geo-types #1063
Changes from 4 commits
1104256
301f24e
818004a
f821560
5a6f511
1a20282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the nostd build, we need to give a fully qualified path to the vec macro. That's the primary change in this commit. But also I noticed these into_vec calls. I don't think we were gaining anything by building an array and then boxing it into a Vec vs. building the |
||
$crate::_alloc::Box::new( | ||
[ | ||
$( | ||
$crate::line_string![$($interior_coord),*] | ||
), * | ||
] | ||
) | ||
) | ||
$crate::_alloc::vec![ | ||
$( | ||
$crate::line_string![$($interior_coord),*] | ||
), * | ||
] | ||
) | ||
}; | ||
( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of where it's less nice. Unlike the
serde_json::json!
macro, you can't embed expressions. Thewkt!
macro only accepts literals.