Michael-F-Bryan / include_dir

The logical evolution of the include_str macro for embedding a directory tree into your binary.
https://michael-f-bryan.github.io/include_dir
MIT License
339 stars 38 forks source link

specify 'a lifetime on file contents #73

Closed jbr closed 2 years ago

jbr commented 2 years ago

Without this, the lifetime of &self is inferred, which might not live as long as 'a (often/always 'static)

I believe this is semver-patch because 'a always outlives the self borrow lifetime

Michael-F-Bryan commented 2 years ago

Yeah, as written this just requires a patch release, but unfortunately it also conflicts with compression 😞

I originally returned a value with the same lifetime as the type just like you've done, but when the file contents are lazily decompressed you will find the returned content's lifetime can't outlive self.

Well... You can extend it to 'static by leaking the allocation, but my opinion is that your API has problems if it can only be implemented by leaking memory.