netcorehost/pdcstring/impl/other/
ext.rs1use std::ffi::{CStr, CString};
2
3use crate::pdcstring::{PdCStr, PdCString};
4
5pub trait PdCStringExt
6where
7 Self: Sized,
8{
9 fn from_c_string(s: CString) -> Self;
10 fn into_c_string(self) -> CString;
11}
12
13impl PdCStringExt for PdCString {
14 fn from_c_string(s: CString) -> Self {
15 Self::from_inner(s)
16 }
17
18 fn into_c_string(self) -> CString {
19 self.into_inner()
20 }
21}
22
23pub trait PdCStrExt {
24 fn from_c_str(s: &CStr) -> &Self;
25 fn as_c_str(&self) -> &CStr;
26}
27
28impl PdCStrExt for PdCStr {
29 fn from_c_str(s: &CStr) -> &Self {
30 Self::from_inner(s)
31 }
32
33 fn as_c_str(&self) -> &CStr {
34 self.as_inner()
35 }
36}