Skip to content

Compiling with csgrs with the f32 feature fails #33

@winksaville

Description

@winksaville

Attempting to compile app cubes when using v0.16.0 of csgrs and trying to use the f32 feature fails to compile:

$ cargo build
   Compiling csgrs v0.16.0
error[E0277]: the trait bound `Coord: From<[f32; 2]>` is not satisfied
   --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:525:39
    |
525 |         let line_string: LineString = vec![[0.0, 0.0], [width, 0.0], [0.0, height]].into();
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- required by a bound introduced by this call
    |                                       |
    |                                       the trait `From<[f32; 2]>` is not implemented for `Coord`
    |
    = help: the trait `From<[f32; 2]>` is not implemented for `Coord`
            but trait `From<Coordinate>` is implemented for it
    = help: for that trait implementation, expected `Coordinate`, found `[f32; 2]`
    = note: required for `[f32; 2]` to implement `Into<Coord>`
    = note: required for `geo::LineString` to implement `From<Vec<[f32; 2]>>`
    = note: 1 redundant requirement hidden
    = note: required for `Vec<[f32; 2]>` to implement `Into<geo::LineString>`

error[E0308]: mismatched types
   --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:527:65
    |
527 |         CSG::from_geo(GeometryCollection(vec![Geometry::Polygon(polygon)]), metadata)
    |                                               ----------------- ^^^^^^^ expected `Polygon<f32>`, found `Polygon`
    |                                               |
    |                                               arguments to this enum variant are incorrect
    |
    = note: expected struct `geo::Polygon<f32>`
               found struct `geo::Polygon<f64>`
note: tuple variant defined here
   --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/geo-types-0.7.15/src/geometry/mod.rs:56:5
    |
56  |     Polygon(Polygon<T>),
    |     ^^^^^^^

error[E0308]: arguments to this function are incorrect
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:3071:37
     |
3071 |                     let new_mpoly = buffer_polygon(poly, distance);
     |                                     ^^^^^^^^^^^^^^       -------- expected `f64`, found `f32`
     |
note: expected `&Polygon`, found `&Polygon<f32>`
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:3071:52
     |
3071 |                     let new_mpoly = buffer_polygon(poly, distance);
     |                                                    ^^^^
     = note: expected reference `&geo::Polygon<f64>`
                found reference `&geo::Polygon<f32>`
note: function defined here
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/geo-buf-0.1.0/src/lib.rs:175:8
     |
175  | pub fn buffer_polygon(input_polygon: &Polygon, distance: f64) -> MultiPolygon {
     |        ^^^^^^^^^^^^^^
help: you can convert an `f32` to an `f64`
     |
3071 |                     let new_mpoly = buffer_polygon(poly, distance.into());
     |                                                                  +++++++

error[E0308]: arguments to this function are incorrect
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:3075:37
     |
3075 |                     let new_mpoly = buffer_multi_polygon(mpoly, distance);
     |                                     ^^^^^^^^^^^^^^^^^^^^        -------- expected `f64`, found `f32`
     |
note: expected `&MultiPolygon`, found `&MultiPolygon<f32>`
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:3075:58
     |
3075 |                     let new_mpoly = buffer_multi_polygon(mpoly, distance);
     |                                                          ^^^^^
     = note: expected reference `&geo::MultiPolygon<f64>`
                found reference `&geo::MultiPolygon<f32>`
note: function defined here
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/geo-buf-0.1.0/src/lib.rs:238:8
     |
238  | pub fn buffer_multi_polygon(input_multi_polygon: &MultiPolygon, distance: f64) -> MultiPolygon {
     |        ^^^^^^^^^^^^^^^^^^^^
help: you can convert an `f32` to an `f64`
     |
3075 |                     let new_mpoly = buffer_multi_polygon(mpoly, distance.into());
     |                                                                         +++++++

error[E0308]: mismatched types
    --> /home/wink/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/csgrs-0.16.0/src/csg.rs:3088:23
     |
3088 |             geometry: new_collection,
     |                       ^^^^^^^^^^^^^^ expected `GeometryCollection<f32>`, found `GeometryCollection`
     |
     = note: expected struct `geo::GeometryCollection<f32>`
                found struct `geo::GeometryCollection<f64>`

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `csgrs` (lib) due to 5 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions