#static #global #singleton

yanked staticslot

Atomic pointer type for holding static variables

Uses old Rust 2015

0.2.1 Dec 21, 2017
0.2.0 Jul 16, 2017
0.1.0 Jul 15, 2017

#15 in #singleton

MIT license

122 lines


Atomic pointer type for holding static variables.

Shippable Crates.io Documentation License



Add this to your Cargo.toml file:

staticslot = "0.2"


This crate provides a simple type, StaticSlot<T>, which is designed to make it easy to use static variables without much boilerplate or overhead. Usually you do not need any type of global variable, as it can introduce a number of problems into your code with bugs and testability. That being said, in certain applications a global variable is the most practical or efficient solution. This crate is targeted toward these uses.

A static slot is just a nullable pointer to some heap-allocated value with some extra features. We can declare one like this:

static GLOBAL_STRINGS: StaticSlot<Vec<String>> = StaticSlot::NULL;

Then we can get() and set() the value throughout our program. In addition, a number of convenience methods are also provided. See the documentation for details about semantics and safety.



No runtime deps