Hello,

My first instinct would be: don't... but in the name of science...

Have you tried looking at Stack Overflow ? Just googling around I found:
http://stackoverflow.com/questions/19605132/is-it-possible-to-use-global-variables-in-rustwhich
allows you to have a global variable and from there a Singleton seems
easy.

I guess you will need something like Mutex<Option<Type>> if you want lazy
initialization.

-- Matthieu



On Thu, May 15, 2014 at 9:59 AM, Christophe Pedretti <
christophe.pedre...@gmail.com> 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 ?
>
> thanks
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to