Thanks to visit codestin.com
Credit goes to docs.rs

uapi/ustr/
as_ustr.rs

1use crate::*;
2use std::ffi::{CStr, CString};
3
4/// Used for cheap conversion from into `&Ustr`
5pub trait AsUstr {
6    /// Perform the conversion
7    fn as_ustr(&self) -> &Ustr;
8}
9
10impl AsUstr for Ustr {
11    fn as_ustr(&self) -> &Ustr {
12        self
13    }
14}
15
16impl AsUstr for Ustring {
17    fn as_ustr(&self) -> &Ustr {
18        self
19    }
20}
21
22impl AsUstr for CStr {
23    fn as_ustr(&self) -> &Ustr {
24        Ustr::from_c_str(self)
25    }
26}
27
28impl AsUstr for CString {
29    fn as_ustr(&self) -> &Ustr {
30        Ustr::from_c_str(self)
31    }
32}