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
51
52
53
54
55
56
57
58
59
60
61
#![deny(missing_docs)]
#![deny(warnings)]
use std::borrow::ToOwned;
pub trait IntoVec<T> {
#[inline]
fn into_vec(self) -> Vec<T>;
}
impl<T> IntoVec<T> for Vec<T> {
#[inline]
fn into_vec(self) -> Vec<T> { self }
}
impl<'a, T: Clone> IntoVec<T> for &'a [T] {
#[inline]
fn into_vec(self) -> Vec<T> { self.to_vec() }
}
impl<T> IntoVec<T> for Box<[T]> {
#[inline]
fn into_vec(self) -> Vec<T> {
std::slice::SliceExt::into_vec(self)
}
}
impl IntoVec<u8> for String {
#[inline]
fn into_vec(self) -> Vec<u8> { self.into_bytes() }
}
impl<'a> IntoVec<u8> for &'a str {
#[inline]
fn into_vec(self) -> Vec<u8> { self.as_bytes().into_vec() }
}
pub trait IntoString {
fn into_string(self) -> String;
}
impl IntoString for String {
#[inline]
fn into_string(self) -> String { self }
}
impl<'a> IntoString for &'a str {
#[inline]
fn into_string(self) -> String {
self.to_owned()
}
}