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

Type mismatch error while trying to compile examples/simple.rs #4

Open
ngirard opened this issue Mar 4, 2020 · 2 comments
Open

Type mismatch error while trying to compile examples/simple.rs #4

ngirard opened this issue Mar 4, 2020 · 2 comments

Comments

@ngirard
Copy link
Contributor

ngirard commented Mar 4, 2020

Got the following error while trying to compile:

cargo run --example simple
error[E0631]: type mismatch in function arguments
  --> examples/simple.rs:14:36
   |
14 |     ItemList::new(rustofi_entries, Box::new(simple_callback)).display("Select an entry".to_string())
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r mut std::string::String) -> _`
...
17 | pub fn simple_callback(s: &String) -> RustofiResult {
   | --------------------------------------------------- found signature of `for<'r> fn(&'r std::string::String) -> _`
   |
   = note: required because of the requirements on the impl of `rustofi::RustofiCallback<std::string::String>` for `for<'r> fn(&'r std::string::String) -> rustofi::RustofiResult {simple_callback}`
   = note: required for the cast to the object type `dyn for<'r> rustofi::RustofiCallback<std::string::String, Output = std::result::Result<(), std::string::String>>`
@mattlennon3
Copy link

mattlennon3 commented Nov 15, 2020

I get the same issue, the todo_app.rs works when you clone this repo locally and run it, but if you make a fresh project and paste it in as main.rs with the latest rustofi v0.2.2 and other dependencies you get the same error.

I completely accidentally found the fix while trawling through some forums. This will get you compiling:

// change this:
    pub fn toggle_todo(t: &mut TodoItem) -> CallbackResult {

// to this
    pub fn toggle_todo<'r>(t: &'r TodoItem) -> RustofiResult {

// get rid of the 3rd arg in AppPage
        AppPage::<TodoItem>::new(
            todos,
            Box::new(TodoApp::toggle_todo)
        )

Fixing those brings more errors, but they seem easy to overcome, just returning the right values etc. I didn't want to fix the whole file :).

hopefully from here you can use the todo as a good example of how to use this crate.

Still not sure about integrating with rofi properly, but I have an executable I can call and that is good enough atm!

@mattlennon3
Copy link

I made some progress today and I have finally understood what is going on with the AppPage constructor!

The master branch is at version 0.3.0 but the latest crate is 0.2.2. This is why the todo_app works in the repo but not with the crate. I think for now I will just use a locally compiled crate to have 0.3.0 - I need the custom actions for my project.

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

2 participants