Skip to content

Commit

Permalink
bring back manual Default for GeomCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Feb 21, 2022
1 parent 0ee2101 commit 228e65a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion geo-types/src/geometry_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ use std::ops::{Index, IndexMut};
/// println!("{:?}", gc[0]);
/// ```
///
#[derive(Eq, PartialEq, Clone, Debug, Hash, Default)]
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GeometryCollection<T>(pub Vec<Geometry<T>>)
where
T: CoordNum;

// Implementing Default by hand because T does not have Default restriction
// todo: consider adding Default as a CoordNum requirement
impl<T: CoordNum> Default for GeometryCollection<T> {
fn default() -> Self {
GeometryCollection(Vec::new())
}
}

impl<T: CoordNum> GeometryCollection<T> {
/// Return an empty GeometryCollection
pub fn new() -> GeometryCollection<T> {
Expand Down

0 comments on commit 228e65a

Please sign in to comment.