From 950050f4632c82f3bbfa49f58ee642324bf08390 Mon Sep 17 00:00:00 2001 From: icodezjb Date: Fri, 3 Aug 2018 16:58:42 +0800 Subject: [PATCH] use write_all instead of write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit io::Write::write is not guaranteed to process the entire buffer. it return how many bytes were processed, which might be smaller than a given buffer’s length. use write_all instead. --- substrate/codec/src/codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/codec/src/codec.rs b/substrate/codec/src/codec.rs index beee49ba3d8a4..4105e9bdc85bf 100644 --- a/substrate/codec/src/codec.rs +++ b/substrate/codec/src/codec.rs @@ -80,7 +80,7 @@ impl Output for Vec { #[cfg(feature = "std")] impl Output for W { fn write(&mut self, bytes: &[u8]) { - (self as &mut ::std::io::Write).write(bytes).expect("Codec outputs are infallible"); + (self as &mut ::std::io::Write).write_all(bytes).expect("Codec outputs are infallible"); } }