|
1 | 1 | use super::{Buf}; |
2 | 2 |
|
3 | | -use std::io; |
| 3 | +#[cfg(not(feature = "use_std"))] |
| 4 | +use buf::Cursor; |
| 5 | +#[cfg(not(feature = "use_std"))] |
| 6 | +use collections::string::String; |
| 7 | +#[cfg(not(feature = "use_std"))] |
| 8 | +use collections::vec::Vec; |
| 9 | +#[cfg(feature = "use_std")] |
| 10 | +use std::io::Cursor; |
4 | 11 |
|
5 | 12 | /// Conversion into a `Buf` |
6 | 13 | /// |
@@ -56,65 +63,65 @@ impl<T: Buf> IntoBuf for T { |
56 | 63 | } |
57 | 64 |
|
58 | 65 | impl<'a> IntoBuf for &'a [u8] { |
59 | | - type Buf = io::Cursor<&'a [u8]>; |
| 66 | + type Buf = Cursor<&'a [u8]>; |
60 | 67 |
|
61 | 68 | fn into_buf(self) -> Self::Buf { |
62 | | - io::Cursor::new(self) |
| 69 | + Cursor::new(self) |
63 | 70 | } |
64 | 71 | } |
65 | 72 |
|
66 | 73 | impl<'a> IntoBuf for &'a str { |
67 | | - type Buf = io::Cursor<&'a [u8]>; |
| 74 | + type Buf = Cursor<&'a [u8]>; |
68 | 75 |
|
69 | 76 | fn into_buf(self) -> Self::Buf { |
70 | 77 | self.as_bytes().into_buf() |
71 | 78 | } |
72 | 79 | } |
73 | 80 |
|
74 | 81 | impl IntoBuf for Vec<u8> { |
75 | | - type Buf = io::Cursor<Vec<u8>>; |
| 82 | + type Buf = Cursor<Vec<u8>>; |
76 | 83 |
|
77 | 84 | fn into_buf(self) -> Self::Buf { |
78 | | - io::Cursor::new(self) |
| 85 | + Cursor::new(self) |
79 | 86 | } |
80 | 87 | } |
81 | 88 |
|
82 | 89 | impl<'a> IntoBuf for &'a Vec<u8> { |
83 | | - type Buf = io::Cursor<&'a [u8]>; |
| 90 | + type Buf = Cursor<&'a [u8]>; |
84 | 91 |
|
85 | 92 | fn into_buf(self) -> Self::Buf { |
86 | | - io::Cursor::new(&self[..]) |
| 93 | + Cursor::new(&self[..]) |
87 | 94 | } |
88 | 95 | } |
89 | 96 |
|
90 | 97 | // Kind of annoying... but this impl is required to allow passing `&'static |
91 | 98 | // [u8]` where for<'a> &'a T: IntoBuf is required. |
92 | 99 | impl<'a> IntoBuf for &'a &'static [u8] { |
93 | | - type Buf = io::Cursor<&'static [u8]>; |
| 100 | + type Buf = Cursor<&'static [u8]>; |
94 | 101 |
|
95 | 102 | fn into_buf(self) -> Self::Buf { |
96 | | - io::Cursor::new(self) |
| 103 | + Cursor::new(self) |
97 | 104 | } |
98 | 105 | } |
99 | 106 |
|
100 | 107 | impl<'a> IntoBuf for &'a &'static str { |
101 | | - type Buf = io::Cursor<&'static [u8]>; |
| 108 | + type Buf = Cursor<&'static [u8]>; |
102 | 109 |
|
103 | 110 | fn into_buf(self) -> Self::Buf { |
104 | 111 | self.as_bytes().into_buf() |
105 | 112 | } |
106 | 113 | } |
107 | 114 |
|
108 | 115 | impl IntoBuf for String { |
109 | | - type Buf = io::Cursor<Vec<u8>>; |
| 116 | + type Buf = Cursor<Vec<u8>>; |
110 | 117 |
|
111 | 118 | fn into_buf(self) -> Self::Buf { |
112 | 119 | self.into_bytes().into_buf() |
113 | 120 | } |
114 | 121 | } |
115 | 122 |
|
116 | 123 | impl<'a> IntoBuf for &'a String { |
117 | | - type Buf = io::Cursor<&'a [u8]>; |
| 124 | + type Buf = Cursor<&'a [u8]>; |
118 | 125 |
|
119 | 126 | fn into_buf(self) -> Self::Buf { |
120 | 127 | self.as_bytes().into_buf() |
|
0 commit comments