You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm no Rust guy, so I'm having trouble building this (object) struct to allow for Functions to be included. I'm essentially exposing a way for a Window to be created from NodeJS using the Wry Rust library. This library has a way to attach handlers to certain events, and I'm really struggling to figure out how to pass a function in an object from JS to Rust:
I feel like I've tried everything, but I actually don't know if I have. I've tried using a generic (<F> where F: Fn(String) -> bool), both upper and lowercase functions (Option<Fn(String) -> bool> and Option<fn(String) -> bool)>) with the uppercase requiring the dyn keyword and me looping back to "wtf is going on", and the lowercase claiming that Option<fn(String) -> bool> needs to implement ToNapiValue (which it does already, doesn't it?).
It's important that every field is an Option because that's how I'm maintaining that all fields are optional, but I have a feeling that the Options aren't the problem here...
I feel stuck and I don't know how to fix this issue...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm no Rust guy, so I'm having trouble building this (object) struct to allow for Functions to be included. I'm essentially exposing a way for a Window to be created from NodeJS using the Wry Rust library. This library has a way to attach handlers to certain events, and I'm really struggling to figure out how to pass a function in an object from JS to Rust:
I feel like I've tried everything, but I actually don't know if I have. I've tried using a generic (
<F> where F: Fn(String) -> bool
), both upper and lowercase functions (Option<Fn(String) -> bool>
andOption<fn(String) -> bool)>
) with the uppercase requiring thedyn
keyword and me looping back to "wtf is going on", and the lowercase claiming thatOption<fn(String) -> bool>
needs to implementToNapiValue
(which it does already, doesn't it?).It's important that every field is an
Option
because that's how I'm maintaining that all fields are optional, but I have a feeling that theOption
s aren't the problem here...I feel stuck and I don't know how to fix this issue...
Beta Was this translation helpful? Give feedback.
All reactions