embedding: convert callback Option<> matching to map()

This commit is contained in:
Mike Blumenkrantz 2014-11-14 17:17:40 -05:00
parent 11e30731ef
commit 5f10092995
2 changed files with 6 additions and 31 deletions

View file

@ -52,12 +52,7 @@ pub extern "C" fn cef_string_userfree_utf16_free(cs: *mut cef_string_userfree_ut
#[no_mangle]
pub extern "C" fn cef_string_utf8_clear(cs: *mut cef_string_utf8_t) {
unsafe {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut u8;
(*cs).dtor = mem::transmute(0 as *const u8);
@ -136,12 +131,7 @@ pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, out
#[no_mangle]
pub extern "C" fn cef_string_utf16_clear(cs: *mut cef_string_utf16_t) {
unsafe {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut c_ushort;
(*cs).dtor = mem::transmute(0 as *const u8);
@ -196,12 +186,7 @@ pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const c
#[no_mangle]
pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) {
unsafe {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut wchar_t;
(*cs).dtor = mem::transmute(0 as *const u8);