mapeditor / rs-tiled

Reads files from the Tiled editor into Rust
https://crates.io/crates/tiled
MIT License
268 stars 102 forks source link

Updated lifetime of LayerTile returned from TileLayer #254

Closed Anti-Alias closed 1 year ago

Anti-Alias commented 1 year ago

Small PR to change the lifetime specifier of the LayerTile returned by the get_tile methods. Previously, the LayerTile returned by these methods would have the elided lifetime of "self", which is shorter than 'map.

aleokdev commented 1 year ago

Argh, not the first time it has happened. Thanks!

bjorn commented 1 year ago

Just wondering, but aren't these the kind of errors the Rust compiler is supposed to be able to notice? Or is this patch triggered by compiler errors, in usage that our tests and examples aren't covering so far?

aleokdev commented 1 year ago

Both lifetimes are valid, but 'map lasts longer than 'self. There are no tests for it so the compiler accepts it.

aleokdev commented 1 year ago

I forgor to check the changelog again 💀

bjorn commented 1 year ago

Ah, so the lifetime was valid, but shorter than it could be, and for convenience we'd want the lifetime to be as long as possible.

aleokdev commented 1 year ago

Yup, just like in #201.