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

Function result_to_cstring

src/lib.rs:41–48  ·  view source on GitHub ↗
(res: Result<T>)

Source from the content-addressed store, hash-verified

39}
40
41pub fn result_to_cstring<T: ToString>(res: Result<T>) -> CString {
42 let inner = match res {
43 Ok(inn) => format!("{{ \"ok\": {} }}", inn.to_string()),
44 Err(err) => format!("{{ \"err\": \"{}\" }}", err.to_string()),
45 };
46
47 CString::new(inner).unwrap()
48}
49
50macro_rules! export_fn {
51 ($fn_name:ident,String)=> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected