sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
804 stars 76 forks source link

[crates.io newest] dispatch_script_call macro causes E0277 #42

Closed Jimmio92 closed 5 years ago

Jimmio92 commented 5 years ago

Hello all,

error[E0277]: the trait bound `for<'r> (): std::ops::Fn<(&'r [sciter::Value],)>` is not satisfied
  --> src\main.rs:12:2
   |
12 |       dispatch_script_call! (
   |  _____^
13 | |         fn do_tag_search(String);
14 | |     );
   | |______^ the trait `for<'r> std::ops::Fn<(&'r [sciter::Value],)>` is not implemented for `()`
   |
   = note: required because of the requirements on the impl of `std::convert::From<()>` for `sciter::Value`
   = note: required by `std::convert::From::from`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
#[macro_use] extern crate sciter;

struct EventHandler;

impl EventHandler {
    fn do_tag_search(&self, search: String) {
        println!("Requested tag search: {}", search);
    }
}

impl sciter::EventHandler for EventHandler {
    dispatch_script_call! (
        fn do_tag_search(String);
    );
}

fn main() {
    let handler = EventHandler { };
    let mut frame = sciter::Window::new();
    frame.event_handler(handler);
    frame.load_file("src/main.html");
    frame.run_app();
}

I have no idea what's going on; I suspect something's changed that's not shown in the examples preventing this from working. Any ideas?

pravic commented 5 years ago

Yeah, you have to return something. However, I think that the empty return value has some rights to live, too.

Try master. If it's okay, I'll update this crate as well.