我想使用两个外部库(geo-types-0.6.0和geo-offset-0.1.0)来执行几何算法。
下面的例子看起来不错:Line类型是在库geo_types中定义的。此外,Offset特征是用geo_offset编写的。包含此特性将导致Line类型实现方法offset。然而,我得到了以下错误:
no method named `offset` found for struct `geo_types::line::Line<float>` in the current scope
除此之外,VS代码中的rust-analyzer告诉我,没有使用包含的特征Offset。为什么会这样呢?
use geo_types::{Coordinate, Line};
use geo_offset::Offset;
let line = Line::new(
Coordinate { x: 0.0, y: 0.0 },
Coordinate { x: 1.0, y: 8.0 },
);
let line_with_offset = line.offset(2.0)?;发布于 2020-09-11 16:21:14
geo-offset机箱为geo::Line实现Offset特征,而不是geo_types::Line (src -搜索geo::Line)。因此,即使geo::Line只是geo_types::Line的再导出,rust编译器也看不到这一点,只知道geo::Line的Offset实现。
https://stackoverflow.com/questions/63843133
复制相似问题