1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![allow(clippy::wrong_self_convention)]
use alloc::borrow::ToOwned;
use alloc::boxed::Box;
pub trait ToBoxed: ToOwned {
fn to_boxed(o: Self::Owned) -> Box<Self>;
}
impl ToBoxed for str {
#[inline]
fn to_boxed(o: Self::Owned) -> Box<Self> {
o.into_boxed_str()
}
}
impl<T: Clone> ToBoxed for [T] {
#[inline]
fn to_boxed(o: Self::Owned) -> Box<Self> {
o.into_boxed_slice()
}
}
#[cfg(feature = "std")]
impl ToBoxed for std::ffi::CStr {
#[inline]
fn to_boxed(o: Self::Owned) -> Box<Self> {
o.into_boxed_c_str()
}
}
#[cfg(feature = "std")]
impl ToBoxed for std::ffi::OsStr {
#[inline]
fn to_boxed(o: Self::Owned) -> Box<Self> {
o.into_boxed_os_str()
}
}
#[cfg(feature = "std")]
impl ToBoxed for std::path::Path {
#[inline]
fn to_boxed(o: Self::Owned) -> Box<Self> {
o.into_boxed_path()
}
}