From c58cf56863850493e59f297ddc266ce41ff2a2c9 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Thu, 17 Dec 2015 22:06:18 +0100 Subject: [PATCH] Silence warning with minor cleanup --- core-foundation/src/string.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core-foundation/src/string.rs b/core-foundation/src/string.rs index 37f06b4..3303511 100644 --- a/core-foundation/src/string.rs +++ b/core-foundation/src/string.rs @@ -19,7 +19,6 @@ use std::fmt; use std::str::{self, FromStr}; use std::mem; use std::ptr; -use std::vec::Vec; use std::ffi::CStr; /// An immutable string in one of a variety of encodings. @@ -77,8 +76,7 @@ impl fmt::Display for CFString { &mut bytes_required); // Then, allocate the buffer and actually copy. - let mut buffer = Vec::with_capacity(bytes_required as usize); - for _ in (0..bytes_required) { buffer.push('\x00' as u8) } + let mut buffer = vec![b'\x00'; bytes_required as usize]; let mut bytes_used: CFIndex = 0; let chars_written = CFStringGetBytes(self.0,