File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,9 @@ impl StrWriter for discard {
290290 }
291291}
292292
293+ // A [Writer] on which all Write calls succeed without doing anything.
294+ let mut Discard = discard{}
295+
293296// Reads from R but limits the amount of
294297// data returned to just N bytes. Each call to Read
295298// updates N to reflect the new amount remaining.
@@ -321,8 +324,23 @@ impl Reader for LimitedReader {
321324 }
322325}
323326
324- // A [Writer] on which all Write calls succeed without doing anything.
325- let mut Discard = discard{}
327+ // Returns a [ReadCloser] with a no-op Close method wrapping
328+ // the provided [Reader] r.
329+ fn NopCloser(mut r: Reader): ReadCloser {
330+ ret nopCloser{r}
331+ }
332+
333+ struct nopCloser {
334+ r: Reader
335+ }
336+
337+ impl ReadCloser for nopCloser {
338+ fn Read(mut *self, mut p: []byte)!: int {
339+ ret self.r.Read(p)?
340+ }
341+
342+ fn Close(mut *self)! {}
343+ }
326344
327345// Copies n bytes (or until an error) from src to dst.
328346// It returns the number of bytes copied and throws the earliest
You can’t perform that action at this time.
0 commit comments