diff --git a/Makefile.in b/Makefile.in index cda3e7a..683cf41 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) $< --lib --out-dir . + $(RUSTC) $(RUSTFLAGS) $< --crate-type=lib --out-dir . touch $@ core_foundation-test: lib.rs $(RUST_SRC) diff --git a/base.rs b/base.rs index d42e2a2..f7f20a4 100644 --- a/base.rs +++ b/base.rs @@ -9,6 +9,7 @@ use std::cast; use std::libc::{c_long, c_ulong}; +use std::num::Bounded; pub type Boolean = u8; diff --git a/lib.rs b/lib.rs index d422295..57b9f81 100644 --- a/lib.rs +++ b/lib.rs @@ -9,7 +9,7 @@ #[crate_id = "github.com/mozilla-servo/rust-core-foundation#core_foundation:0.1"]; -extern mod std; +extern crate std; pub mod array; pub mod base; diff --git a/string.rs b/string.rs index 69ff0e3..7babf2a 100644 --- a/string.rs +++ b/string.rs @@ -15,6 +15,7 @@ use base::{Boolean, CFAllocatorRef, CFIndex, CFIndexConvertible, CFOptionFlags, use base::{CFRelease, CFTypeID, TCFType, kCFAllocatorDefault, kCFAllocatorNull}; use std::cast; +use std::fmt; use std::libc; use std::ptr; use std::vec; @@ -259,8 +260,8 @@ impl FromStr for CFString { } } -impl ToStr for CFString { - fn to_str(&self) -> ~str { +impl fmt::Show for CFString { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe { let char_len = self.char_len(); let range = CFRange::init(0, char_len); @@ -294,11 +295,14 @@ impl ToStr for CFString { assert!(bytes_used == buffer.len().to_CFIndex()); // Then, reinterpret it as as string. You have been warned! - cast::transmute(buffer) + let s: ~str = cast::transmute(buffer); + + write!(f.buf, "{}", s) } } } + impl CFString { /// Like `CFString::from_string`, but references a string that can be used as a backing store /// by virtue of being statically allocated. diff --git a/url.rs b/url.rs index b8d2704..1fc04ec 100644 --- a/url.rs +++ b/url.rs @@ -12,6 +12,7 @@ #[allow(non_uppercase_statics)]; use base::{CFOptionFlags, CFRelease, CFTypeID, TCFType}; +use std::fmt; use string::{CFString, CFStringRef}; struct __CFURL; @@ -49,12 +50,13 @@ impl TCFType for CFURL { } } -impl ToStr for CFURL { +impl fmt::Show for CFURL { #[inline] - fn to_str(&self) -> ~str { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe { let string: CFString = TCFType::wrap_under_get_rule(CFURLGetString(self.obj)); - string.to_str() + let s: ~str = string.to_str(); + write!(f.buf, "{}", s) } } }