MCPcopy Create free account
hub / github.com/bytesnake/vim-graphical-preview / singleton

Function singleton

src/lib.rs:20–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20fn 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
41pub fn result_to_cstring<T: ToString>(res: Result<T>) -> CString {
42 let inner = match res {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected