Merge pull request #32 from mozilla-servo/rustup_20140510

Rust upgrade
This commit is contained in:
Jack Moffitt
2014-05-14 14:07:20 -06:00
2 changed files with 4 additions and 9 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs')
all: libcore_foundation.dummy
libcore_foundation.dummy: lib.rs $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< --crate-type=lib --out-dir .
$(RUSTC) $(RUSTFLAGS) $< --out-dir .
touch $@
core_foundation-test: lib.rs $(RUST_SRC)
+3 -8
View File
@@ -15,11 +15,10 @@ use base::{Boolean, CFAllocatorRef, CFIndex, CFIndexConvertible, CFOptionFlags,
use base::{CFRelease, CFTypeID, TCFType, kCFAllocatorDefault, kCFAllocatorNull};
use libc;
use std::cast;
use std::fmt;
use std::from_str::FromStr;
use std::ptr;
use std::slice;
use std::vec::Vec;
pub type UniChar = libc::c_ushort;
@@ -279,7 +278,7 @@ impl fmt::Show for CFString {
&mut bytes_required);
// Then, allocate the buffer and actually copy.
let buffer: ~[u8] = slice::from_elem(bytes_required as uint, '\x00' as u8);
let buffer: Vec<u8> = Vec::from_elem(bytes_required as uint, '\x00' as u8);
let mut bytes_used: CFIndex = 0;
let chars_written = CFStringGetBytes(self.obj,
range,
@@ -294,11 +293,7 @@ impl fmt::Show for CFString {
// This is dangerous; we over-allocate and null-terminate the string (during
// initialization).
assert!(bytes_used == buffer.len().to_CFIndex());
// Then, reinterpret it as as string. You have been warned!
let s: ~str = cast::transmute(buffer);
write!(f.buf, "{}", s)
write!(f.buf, "{}", StrBuf::from_utf8(buffer).unwrap())
}
}
}