I guess I'm not understanding the static concept of Rust in case of how it is treated across crates.
I've created a crate lets name it
provider. This crate provides a public static variable:
pub static VARIABLE: SomeType = SomeType::new();
SomeType here takes care that mutable exclusive access to data and functions of the
Now I've two different crates that use this one as a dependency. Let's call them
My expectation now was, that either
consumer see's always the same static
VARIABLE. So if
consumer-one does some initialization on this static variable the
consumer-two could expect the static variable has performed initialization as well. But I've seen that each crate seem to "instantiate" it's own version of the static
VARIABLE. If I print the linker symbols created for the final binary I have confirmed that there are really 2 different symbols for the same static
The question now is: Is this function as designed and I do something wrong conceptually are is there a specific trick required to make this
global across the both consumer crates?
pub static seem to be a dependent crate
local is quite confusing me....
Thanks in advance giving me a clue...