From d50d6b302a12afc4efa1892173d9428e261d0167 Mon Sep 17 00:00:00 2001 From: icodezjb <icodezjb@163.com> Date: Fri, 3 Aug 2018 18:25:21 +0800 Subject: [PATCH] use write_all instead of write (#488) 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/substrate/codec/src/codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/substrate/codec/src/codec.rs b/substrate/substrate/codec/src/codec.rs index beee49ba3d8..4105e9bdc85 100644 --- a/substrate/substrate/codec/src/codec.rs +++ b/substrate/substrate/codec/src/codec.rs @@ -80,7 +80,7 @@ impl Output for Vec<u8> { #[cfg(feature = "std")] impl<W: ::std::io::Write> 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"); } } -- GitLab