@@ -64,7 +64,7 @@ use crate::io::{self, buffered::LineWriterShim, BufWriter, IntoInnerError, IoSli
64
64
/// }
65
65
/// ```
66
66
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
67
- pub struct LineWriter < W : Write > {
67
+ pub struct LineWriter < W : ? Sized + Write > {
68
68
inner : BufWriter < W > ,
69
69
}
70
70
@@ -109,27 +109,6 @@ impl<W: Write> LineWriter<W> {
109
109
LineWriter { inner : BufWriter :: with_capacity ( capacity, inner) }
110
110
}
111
111
112
- /// Gets a reference to the underlying writer.
113
- ///
114
- /// # Examples
115
- ///
116
- /// ```no_run
117
- /// use std::fs::File;
118
- /// use std::io::LineWriter;
119
- ///
120
- /// fn main() -> std::io::Result<()> {
121
- /// let file = File::create("poem.txt")?;
122
- /// let file = LineWriter::new(file);
123
- ///
124
- /// let reference = file.get_ref();
125
- /// Ok(())
126
- /// }
127
- /// ```
128
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
129
- pub fn get_ref ( & self ) -> & W {
130
- self . inner . get_ref ( )
131
- }
132
-
133
112
/// Gets a mutable reference to the underlying writer.
134
113
///
135
114
/// Caution must be taken when calling methods on the mutable reference
@@ -184,8 +163,31 @@ impl<W: Write> LineWriter<W> {
184
163
}
185
164
}
186
165
166
+ impl < W : ?Sized + Write > LineWriter < W > {
167
+ /// Gets a reference to the underlying writer.
168
+ ///
169
+ /// # Examples
170
+ ///
171
+ /// ```no_run
172
+ /// use std::fs::File;
173
+ /// use std::io::LineWriter;
174
+ ///
175
+ /// fn main() -> std::io::Result<()> {
176
+ /// let file = File::create("poem.txt")?;
177
+ /// let file = LineWriter::new(file);
178
+ ///
179
+ /// let reference = file.get_ref();
180
+ /// Ok(())
181
+ /// }
182
+ /// ```
183
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
184
+ pub fn get_ref ( & self ) -> & W {
185
+ self . inner . get_ref ( )
186
+ }
187
+ }
188
+
187
189
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
188
- impl < W : Write > Write for LineWriter < W > {
190
+ impl < W : ? Sized + Write > Write for LineWriter < W > {
189
191
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
190
192
LineWriterShim :: new ( & mut self . inner ) . write ( buf)
191
193
}
@@ -216,7 +218,7 @@ impl<W: Write> Write for LineWriter<W> {
216
218
}
217
219
218
220
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
219
- impl < W : Write > fmt:: Debug for LineWriter < W >
221
+ impl < W : ? Sized + Write > fmt:: Debug for LineWriter < W >
220
222
where
221
223
W : fmt:: Debug ,
222
224
{
0 commit comments