ctor 1.0.3

Global, no_std-compatible constructors for all platforms that run before main (like C/C++ __attribute__((constructor)))
Documentation
//! Examples from the `README`.
#![cfg_attr(linktime_used_linker, feature(used_with_arg))]

use ctor::ctor;
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};

static INITED: AtomicBool = AtomicBool::new(false);

#[ctor(unsafe)]
fn foo() {
    INITED.store(true, Ordering::SeqCst);
}

#[ctor(unsafe)]
/// This is an immutable static, evaluated at init time.
static STATIC_CTOR: HashMap<u32, &'static str> = {
    let mut m = HashMap::new();
    m.insert(0, "foo");
    m.insert(1, "bar");
    m.insert(2, "baz");
    m
};

fn main() {
    assert!(INITED.load(Ordering::SeqCst));
    assert_eq!(STATIC_CTOR.get(&1), Some(&"bar"));
}