]> git.lizzy.rs Git - rust.git/commitdiff
Simplify Windows stdout/stderr
authorOliver Middleton <olliemail27@gmail.com>
Thu, 10 Mar 2016 23:59:28 +0000 (23:59 +0000)
committerOliver Middleton <olliemail27@gmail.com>
Thu, 10 Mar 2016 23:59:28 +0000 (23:59 +0000)
src/libstd/sys/windows/stdio.rs

index 190c257162822272f95cd4eb1e13db955644d5de..a7110044d7f81ebd43f95f8ab2373cb402ff5530 100644 (file)
@@ -69,8 +69,7 @@ fn write(out: &Output, data: &[u8]) -> io::Result<usize> {
     // [1]: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/1232
     // [2]: http://www.mail-archive.com/log4net-dev@logging.apache.org/msg00661.html
     const OUT_MAX: usize = 8192;
-    let data_len;
-    let utf16 = match str::from_utf8(data).ok() {
+    let (utf16, data_len) = match str::from_utf8(data).ok() {
         Some(mut utf8) => {
             if utf8.len() > OUT_MAX {
                 let mut new_len = OUT_MAX;
@@ -79,8 +78,7 @@ fn write(out: &Output, data: &[u8]) -> io::Result<usize> {
                 }
                 utf8 = &utf8[..new_len];
             }
-            data_len = utf8.len();
-            utf8.encode_utf16().collect::<Vec<u16>>()
+            (utf8.encode_utf16().collect::<Vec<u16>>(), utf8.len())
         }
         None => return Err(invalid_encoding()),
     };