io: make new_multi_writer use varargs (#10062)
parent
6a54f3a84d
commit
26652c8a23
|
@ -6,7 +6,7 @@ module io
|
||||||
// full length an error is returned and writing to other writers stops, and if
|
// full length an error is returned and writing to other writers stops, and if
|
||||||
// any writer returns an error the error is returned immediately and writing to
|
// any writer returns an error the error is returned immediately and writing to
|
||||||
// other writers stops.
|
// other writers stops.
|
||||||
pub fn new_multi_writer(writers []Writer) Writer {
|
pub fn new_multi_writer(writers ...Writer) Writer {
|
||||||
return &MultiWriter{
|
return &MultiWriter{
|
||||||
writers: writers
|
writers: writers
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ module io
|
||||||
fn test_multi_writer_write_successful() {
|
fn test_multi_writer_write_successful() {
|
||||||
w0 := TestWriter{}
|
w0 := TestWriter{}
|
||||||
w1 := TestWriter{}
|
w1 := TestWriter{}
|
||||||
mw := new_multi_writer([w0, w1])
|
mw := new_multi_writer(w0, w1)
|
||||||
n := mw.write('0123456789'.bytes()) or {
|
n := mw.write('0123456789'.bytes()) or {
|
||||||
assert false
|
assert false
|
||||||
return
|
return
|
||||||
|
@ -16,7 +16,7 @@ fn test_multi_writer_write_successful() {
|
||||||
fn test_multi_writer_write_incomplete() {
|
fn test_multi_writer_write_incomplete() {
|
||||||
w0 := TestWriter{}
|
w0 := TestWriter{}
|
||||||
w1 := TestIncompleteWriter{}
|
w1 := TestIncompleteWriter{}
|
||||||
mw := new_multi_writer([w0, w1])
|
mw := new_multi_writer(w0, w1)
|
||||||
n := mw.write('0123456789'.bytes()) or {
|
n := mw.write('0123456789'.bytes()) or {
|
||||||
assert w0.bytes == '0123456789'.bytes()
|
assert w0.bytes == '0123456789'.bytes()
|
||||||
assert w1.bytes == '012345678'.bytes()
|
assert w1.bytes == '012345678'.bytes()
|
||||||
|
@ -29,7 +29,7 @@ fn test_multi_writer_write_error() {
|
||||||
w0 := TestWriter{}
|
w0 := TestWriter{}
|
||||||
w1 := TestErrorWriter{}
|
w1 := TestErrorWriter{}
|
||||||
w2 := TestWriter{}
|
w2 := TestWriter{}
|
||||||
mw := new_multi_writer([w0, w1, w2])
|
mw := new_multi_writer(w0, w1, w2)
|
||||||
n := mw.write('0123456789'.bytes()) or {
|
n := mw.write('0123456789'.bytes()) or {
|
||||||
assert w0.bytes == '0123456789'.bytes()
|
assert w0.bytes == '0123456789'.bytes()
|
||||||
assert w2.bytes == []
|
assert w2.bytes == []
|
||||||
|
|
Loading…
Reference in New Issue