Rust geojson : expected enum found reference

Viewed 115

very new to Rust, I am literally copying and pasting the example from this page https://docs.rs/geojson/0.19.0/geojson/enum.Value.html#conversion-from-geo_types, which is:

let point = geo_types::Point::new(2., 9.);
assert_eq!(
geojson::Value::from(&point),
geojson::Value::Point(vec![2., 9.]),
);

I get the following error:

let point = geo_types::Point::new(2., 9.);

mismatched types

note:   expected enum `geojson::Value`
  found reference `&geo_types::Point<{float}>`rustc(E0308)

My cargo.toml file looks like this :

[dependencies]
polyline = "0.8.0"
geo-types = "0.6.0"
geojson = "0.19.0"

Could you help me, I looked at the source code, the ::from is behind a feature geo_types, but since I imported the library I thought it would work ... Many Thanks !

1 Answers

You should enable the geo-types feature in geojson

[dependencies]
polyline = "0.8.0"
geo-types = "0.6.0"
geojson = { version = "0.19.0", features = ["geo-types"] }
Related