Skip to content
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

allow specifying a different content for adjacently tagged enums #2885

Open
murl-digital opened this issue Jan 22, 2025 · 0 comments
Open

allow specifying a different content for adjacently tagged enums #2885

murl-digital opened this issue Jan 22, 2025 · 0 comments

Comments

@murl-digital
Copy link

i'm writing my own representation of the geojson format, and the rfc states that all geojson objects have a type field and all types have a coordinates field to store location data, except GeometryCollection, which is called geometries instead.

see: the examples

my proposed solution would look something like this:

#[derive(Serialize, Deserialize)]
#[serde(tag = "type", content = "coordinates")]
pub enum Geometry {
    Point(Position),
    MultiPoint(Vec<Position>),
    LineString(Vec<Position>),
    MultiLineString(Vec<Vec<Position>>),
    Polygon(Vec<Vec<Position>>),
    #[serde(content = "geometries")]
    GeometryCollection(Vec<Geometry>)
}

looking at what deserialize expands to, i can't immediately tell if this is doable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant