librustc_llvm: use unboxed closures

This commit is contained in:
Jorge Aparicio 2014-12-08 20:17:18 -05:00
parent 3739a2427b
commit 933e7b4a3e

View File

@ -23,6 +23,7 @@
#![feature(globs)]
#![feature(link_args)]
#![feature(unboxed_closures)]
extern crate libc;
@ -2206,7 +2207,7 @@ pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
(*sr).borrow_mut().push_all(slice);
}
pub fn build_string(f: |RustStringRef|) -> Option<String> {
pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){
let mut buf = RefCell::new(Vec::new());
f(&mut buf as RustStringRepr as RustStringRef);
String::from_utf8(buf.into_inner()).ok()