On 15/05/2014 08:59, Christophe Pedretti wrote:
I am trying to implement a Singleton (an object which instantiate only once, successive instantiations returning the object itself). Any tutorial for this ? any idea ? example ? best practice ?
Kimundi published this macro to define lazily initialized statics, which look to me equivalent to singletons although there is no "instanciation" involved:
https://gist.github.com/Kimundi/8782487 http://www.reddit.com/r/rust/comments/1wvxcn/lazily_initialized_statics/ I believe this is only memory-safe with types that satisfy the `Share` kind. http://static.rust-lang.org/doc/master/core/kinds/trait.Share.html -- Simon Sapin _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
