Skip to content

Commit

Permalink
Fix renamed to slice::from_raw_buf warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mttr committed Jan 8, 2015
1 parent 9cfd258 commit 7bbce60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
21 changes: 10 additions & 11 deletions components/script/dom/bindings/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
unsafe {
let mut length = 0;
let chars = JS_GetStringCharsAndLength(cx, s, &mut length);
slice::raw::buf_as_slice(chars, length as uint, |char_vec| {
String::from_utf16(char_vec).unwrap()
})
let char_vec = slice::from_raw_buf(&chars, length as uint);
String::from_utf16(char_vec).unwrap()
}
}

Expand Down Expand Up @@ -328,14 +327,14 @@ impl FromJSValConvertible<()> for ByteString {

let mut length = 0;
let chars = JS_GetStringCharsAndLength(cx, string, &mut length);
slice::raw::buf_as_slice(chars, length as uint, |char_vec| {
if char_vec.iter().any(|&c| c > 0xFF) {
// XXX Throw
Err(())
} else {
Ok(ByteString::new(char_vec.iter().map(|&c| c as u8).collect()))
}
})
let char_vec = slice::from_raw_buf(&chars, length as uint);

if char_vec.iter().any(|&c| c > 0xFF) {
// XXX Throw
Err(())
} else {
Ok(ByteString::new(char_vec.iter().map(|&c| c as u8).collect()))
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions components/util/debug_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::io;
use std::io::Writer;
use std::mem;
use std::mem::size_of;
use std::slice::raw::buf_as_slice;
use std::slice;

fn hexdump_slice(buf: &[u8]) {
let mut stderr = io::stderr();
Expand All @@ -28,6 +28,7 @@ pub fn hexdump<T>(obj: &T) {
unsafe {
let buf: *const u8 = mem::transmute(obj);
debug!("dumping at {:p}", buf);
buf_as_slice(buf, size_of::<T>(), hexdump_slice);
let from_buf = slice::from_raw_buf(&buf, size_of::<T>());
hexdump_slice(from_buf);
}
}

0 comments on commit 7bbce60

Please sign in to comment.