Skip to content

Instantly share code, notes, and snippets.

@sophiajt
Created March 16, 2016 14:43
Show Gist options
  • Save sophiajt/e101bb5649b9ba70b8c8 to your computer and use it in GitHub Desktop.
Save sophiajt/e101bb5649b9ba70b8c8 to your computer and use it in GitHub Desktop.

Try 1: Constrain with FnRegister

pub fn register<T: FnRegister>(&mut self, f: T, name: &str) {
    f.register(self, name);
}

Error: the trait rhai::fn_register::FnRegister is not implemented for the type fn(i32) -> i32 {add} [E0277]

Try 2: Constrain with Fn/closure

pub fn register<T: Fn(U)->V, U, V>(&mut self, f: T, name: &str) {
    f.register(self, name);
}

Error: no method named register found for type T in the current scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment