gpt4 book ai didi

rust - Rust Geojson : expected enum found reference

转载 作者:行者123 更新时间:2023-12-03 11:30:46 24 4
gpt4 key购买 nike

对于Rust来说还很陌生,我实际上是从此页面https://docs.rs/geojson/0.19.0/geojson/enum.Value.html#conversion-from-geo_types复制并粘贴示例,即:

let point = geo_types::Point::new(2., 9.);
assert_eq!(
geojson::Value::from(&point),
geojson::Value::Point(vec![2., 9.]),
);
我收到以下错误:
let point = geo_types::Point::new(2., 9.);

mismatched types

note: expected enum `geojson::Value`
found reference `&geo_types::Point<{float}>`rustc(E0308)
我的cargo.toml文件如下所示:
[dependencies]
polyline = "0.8.0"
geo-types = "0.6.0"
geojson = "0.19.0"
您能帮我吗,我看了看源代码,:: from位于要素geo_types的后面,但是由于我导入了库,所以我认为它可以工作...非常感谢!

最佳答案

您应该在geo-types中启用geojson功能

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

关于rust - Rust Geojson : expected enum found reference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63868115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com