SergioBenitez / state

A Rust library for safe and effortless global and thread-local state management.
Other
213 stars 14 forks source link

What happens if two libraries use state? #1

Closed awelkie closed 7 years ago

awelkie commented 7 years ago

If two libraries (or a library and an application) use state, does their state collide or does each library get a separate state container?

SergioBenitez commented 7 years ago

Thanks so much for this issue. I overlooked this entirely on the first iteration. The answer in 0.1 was that the state would indeed collide. I hadn't initially considered this because I designed the library with the expectation that only private types would be stored in a container. This is a bad assumption in general, and it's too strong of a restriction to impose.

This limitation has been removed entirely. Unfortunately, it comes at the cost of now requiring nightly for its const_fn feature. In any case, state is now local to the binary. What's more, state need-not be static. Free free to look over the documentation for the entirely new API.

SergioBenitez commented 7 years ago

Closing this out. :)

Thank you, again, for this!