()
| 18 | } |
| 19 | |
| 20 | fn singleton() -> &'static SingletonReader { |
| 21 | // Create an uninitialized static |
| 22 | static mut SINGLETON: MaybeUninit<SingletonReader> = MaybeUninit::uninit(); |
| 23 | static ONCE: Once = Once::new(); |
| 24 | |
| 25 | unsafe { |
| 26 | ONCE.call_once(|| { |
| 27 | // Make it |
| 28 | let singleton = SingletonReader { |
| 29 | inner: RefCell::new(render::Render::new()), |
| 30 | }; |
| 31 | // Store it to the static var, i.e. initialize it |
| 32 | SINGLETON.write(singleton); |
| 33 | }); |
| 34 | |
| 35 | // Now we give out a shared reference to the data, which is safe to use |
| 36 | // concurrently. |
| 37 | SINGLETON.assume_init_ref() |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | pub fn result_to_cstring<T: ToString>(res: Result<T>) -> CString { |
| 42 | let inner = match res { |
nothing calls this directly
no outgoing calls
no test coverage detected