macro_rules! lazy_static {
(static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
lazy_static!(PRIV static ref $N : $T = $e; $($t)*);
};
(pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
lazy_static!(PUB static ref $N : $T = $e; $($t)*);
};
($VIS:ident static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
lazy_static!(MAKE TY $VIS $N);
impl ::std::ops::Deref for $N {
type Target = $T;
fn deref<'a>(&'a self) -> &'a $T {
#[inline(always)]
fn __static_ref_initialize() -> Box<$T> { Box::new($e) }
unsafe {
use std::sync::{Once, ONCE_INIT};
use std::mem::transmute;
#[inline(always)]
fn require_sync<T: Sync>(_: &T) { }
static mut DATA: *const $T = 0 as *const $T;
static mut ONCE: Once = ONCE_INIT;
ONCE.call_once(|| {
DATA = transmute::<Box<$T>, *const $T>(__static_ref_initialize());
});
let static_ref = &*DATA;
require_sync(static_ref);
static_ref
}
}
}
lazy_static!($($t)*);
};
(MAKE TY PUB $N:ident) => {
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub struct $N {__private_field: ()}
pub static $N: $N = $N {__private_field: ()};
};
(MAKE TY PRIV $N:ident) => {
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
struct $N {__private_field: ()}
static $N: $N = $N {__private_field: ()};
};
() => ()
}
Keyboard shortcuts
- ?
- Show this help dialog
- S
- Focus the search field
- ⇤
- Move up in search results
- ⇥
- Move down in search results
- ⏎
- Go to active search result
Search tricks
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
, enum
,
trait
, typedef
(or
tdef
).
Search functions by type signature (e.g.
vec -> usize
)