georust / geos

Rust bindings for GEOS
https://docs.rs/geos/
MIT License
122 stars 41 forks source link

Why I can only create Geometry<'static>? #152

Closed ManeraKai closed 4 months ago

ManeraKai commented 4 months ago

This is what I want

use geos::Geometry;
fn point() -> Geometry {
    let r = Geometry::create_empty_point().unwrap();
    r
}

but it's forcing me to have it 'static

use geos::Geometry;
fn point() -> Geometry<'static> {
    let r = Geometry::create_empty_point().unwrap();
    r
}

I don't want it to be static. I want to free it from memory after I finish. It's giving me memory leaks.

GuillaumeGomez commented 4 months ago

It's an issue indeed. Not sure why the lifetime is needed here...

ManeraKai commented 4 months ago

So removing the lifetimes will resolve it? https://github.com/georust/geos/commit/83c32190fd253fb3459f2746d89b1906e671d79c

GuillaumeGomez commented 4 months ago

PR welcome. :)