I am trying to write a native wrapper for
https://github.com/pascalj/rust-expat
(BTW, if there is a native Rust XML parser, I am interested to hear
about it, did not find it). I have trouble calling back into Rust
from C code:
fn set_element_handlers(parser: expat::XML_Parser, start_handler:
&fn(tag: &str, attrs: &[@str]), end_handler: &fn(tag: &str)) {
let start_cb = |_user_data: *c_void, c_name: *c_char, _c_attrs: **c_char| {
unsafe {
let name = str::raw::from_c_str(c_name);
start_handler(name, []);
}
};
let end_cb = |_user_data: *c_void, c_name: *c_char| {
unsafe {
let name = str::raw::from_c_str(c_name);
end_handler(name);
}
};
expat::XML_SetElementHandler(parser, start_cb, end_cb);
}
This says that it saw &fn... instead of expected extern fn for the
second and third parameter. Any ideas how to do this?
Thanks.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev