1#![deny(missing_docs)]
2#![deny(warnings)]
3
4use std::borrow::ToOwned;
7
8pub trait IntoVec<T> {
11 #[inline]
13 fn into_vec(self) -> Vec<T>;
14}
15
16impl<T> IntoVec<T> for Vec<T> {
17 #[inline]
18 fn into_vec(self) -> Vec<T> { self }
19}
20
21impl<'a, T: Clone> IntoVec<T> for &'a [T] {
22 #[inline]
23 fn into_vec(self) -> Vec<T> { self.to_vec() }
24}
25
26impl<T> IntoVec<T> for Box<[T]> {
27 #[inline]
28 fn into_vec(self) -> Vec<T> {
29 std::slice::SliceExt::into_vec(self)
30 }
31}
32
33impl IntoVec<u8> for String {
34 #[inline]
35 fn into_vec(self) -> Vec<u8> { self.into_bytes() }
36}
37
38impl<'a> IntoVec<u8> for &'a str {
39 #[inline]
40 fn into_vec(self) -> Vec<u8> { self.as_bytes().into_vec() }
41}
42
43pub trait IntoString {
46 fn into_string(self) -> String;
48}
49
50impl IntoString for String {
51 #[inline]
52 fn into_string(self) -> String { self }
53}
54
55impl<'a> IntoString for &'a str {
56 #[inline]
57 fn into_string(self) -> String {
58 self.to_owned()
59 }
60}
61