Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![cfg_attr(docsrs, feature(doc_cfg))]

use global_str::GlobalStr;
use static_init::constructor;

pub static HOST: GlobalStr = GlobalStr::new();

#[constructor(0)]
extern "C" fn init() {
  let s = hostname::get()
    .map(|v| v.to_string_lossy().into_owned())
    .unwrap_or_default();
  unsafe {
    *HOST.0.get() = Box::leak(s.into_boxed_str());
  }
}