rustofi
rustofi copied to clipboard
Type mismatch error while trying to compile examples/simple.rs
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>>`
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!
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.