zoodex/src/utility.rs

29 lines
632 B
Rust

use std :: ffi :: * ;
use std :: fmt :: * ;
macro_rules ! concat_os_str { (
$ base : expr ,
$ ( $ suffix : expr ) , +
) => { {
let mut base = std :: ffi :: OsString :: from ( $ base ) ;
$ ( base . push ( $ suffix ) ; ) +
base
} } }
pub fn leak < 'l , Type > ( inner : Type ) -> & 'l Type {
Box :: leak ( Box :: new (inner) )
}
pub fn leak_mut < 'l , Type > ( inner : Type ) -> & 'l mut Type {
Box :: leak ( Box :: new (inner) )
}
pub fn to_os_string ( value : impl Display + Sized ) -> OsString {
OsString :: from ( ToString :: to_string ( & value ) )
}
# [ allow (unused_imports) ] pub (crate) use concat_os_str ;