Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a lazy_static string slice to KeySequence.send #31

Open
shubhamvasaikar opened this issue May 14, 2021 · 0 comments
Open

Passing a lazy_static string slice to KeySequence.send #31

shubhamvasaikar opened this issue May 14, 2021 · 0 comments

Comments

@shubhamvasaikar
Copy link

shubhamvasaikar commented May 14, 2021

First of all thank you for the efforts you put into this. I am trying to write an application that will send a key sequence when the F2key is pressed. However this string is not known during compile time and I generate it at run time. For this I am using the lazy_static macro to initialize the string during run time. Here's what my code looks like:

lazy_static! {
    pub static ref MY_STRING: String = some_fn().to_string();
}

fn main() {
    println!("{}", MY_STRING.as_str());
    F2Key.bind(|| KeySequence(MY_STRING.as_str()).send());
    handle_input_events();
}

The println line works fine for this, but the KeySequence line does not. I have verified that the binding works well if I just pass it a string literal, however I do not get any output when I pass the static MY_STRING in this way.

The binding is probably working fine, as the program stops and wait instead of just exiting. Other bindings also function. However, it seems that nothing is getting passed to the send() method when ran this way. Any ideas why this might be happening? Thank you.

Edit: I'm running this on a RHEL-8 machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant