{"action":"created","issue":{"url":"https://api.github.com/repos/gyscos/Cursive/issues/231","repository_url":"https://api.github.com/repos/gyscos/Cursive","labels_url":"https://api.github.com/repos/gyscos/Cursive/issues/231/labels{/name}","comments_url":"https://api.github.com/repos/gyscos/Cursive/issues/231/comments","events_url":"https://api.github.com/repos/gyscos/Cursive/issues/231/events","html_url":"https://github.com/gyscos/Cursive/issues/231","id":312543324,"number":231,"title":"Call_on_id with OnEventView","user":{"login":"xliiv","id":298994,"avatar_url":"https://avatars3.githubusercontent.com/u/298994?v=4","gravatar_id":"","url":"https://api.github.com/users/xliiv","html_url":"https://github.com/xliiv","followers_url":"https://api.github.com/users/xliiv/followers","following_url":"https://api.github.com/users/xliiv/following{/other_user}","gists_url":"https://api.github.com/users/xliiv/gists{/gist_id}","starred_url":"https://api.github.com/users/xliiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xliiv/subscriptions","organizations_url":"https://api.github.com/users/xliiv/orgs","repos_url":"https://api.github.com/users/xliiv/repos","events_url":"https://api.github.com/users/xliiv/events{/privacy}","received_events_url":"https://api.github.com/users/xliiv/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-09T14:01:31Z","updated_at":"2018-04-09T17:01:28Z","closed_at":"2018-04-09T16:44:44Z","author_association":"CONTRIBUTOR","body":"Any idea how to redesign code below to avoid double borrowing?\r\nIn short, I'd like to\r\n1. create a view\r\n2. wrap the view with `OnEventView`\r\n3. trigger some calculation\r\n4. then show dialog with result\r\n\r\n# Problem description\r\n\r\n```rust\r\nextern crate cursive;\r\n\r\nuse cursive::Cursive;\r\nuse cursive::event::Event;\r\nuse cursive::traits::{Boxable, Identifiable};\r\nuse cursive::views::*;\r\n\r\nfn main() {\r\n    let mut c = Cursive::default();\r\n\r\n    let view_id = \"text\";\r\n    let text = TextView::new(\"Text #1\").with_id(view_id);\r\n\r\n    let text = OnEventView::new(text).on_event(Event::CtrlChar('k'), move |c| {\r\n        let mut new_text = \"\".to_string();\r\n        c.call_on_id(&view_id, |view: &mut TextView| {\r\n            new_text = format!(\"new {}\", &*view.get_content().source());\r\n            c.add_layer(Dialog::info(new_text));\r\n        });\r\n    });\r\n\r\n    c.add_layer(text.full_width());\r\n\r\n    c.run();\r\n}\r\n```\r\n\r\n> error[E0500]: closure requires unique access to `c` but `*c` is already borrowed\r\n>   --> examples/xxx.rs:16:32\r\n>    |\r\n> 16 |         c.call_on_id(&view_id, |view: &mut TextView| {\r\n>    |         - borrow occurs here   ^^^^^^^^^^^^^^^^^^^^^ closure construction occurs here\r\n> 17 |             new_text = format!(\"new {}\", &*view.get_content().source());\r\n> 18 |             c.add_layer(Dialog::info(new_text));\r\n>    |             - borrow occurs due to use of `c` in closure\r\n> 19 |         });\r\n>    |          - borrow ends here\r\n> \r\n> error: aborting due to previous error\r\n\r\n\r\n\r\n\r\n# Environment\r\n\r\n* Operating system: linux distribution, windows, macOS, ...\r\nDistributor ID:\tUbuntu\r\nDescription:\tUbuntu 16.04.4 LTS\r\nRelease:\t16.04\r\nCodename:\txenial\r\n\r\n* Backend used: ncurses\r\n\r\n  * If using ncurses on linux, ncurses version? (run `grep \"define NCURSES_VERSION \" /usr/include/curses.h`)\r\n#define NCURSES_VERSION \"6.0\"\r\n\r\n* Current locale (run `locale` in a terminal).\r\nLANG=en_US.UTF-8\r\nLANGUAGE=\r\nLC_CTYPE=\"en_US.UTF-8\"\r\nLC_NUMERIC=pl_PL.UTF-8\r\nLC_TIME=pl_PL.UTF-8\r\nLC_COLLATE=\"en_US.UTF-8\"\r\nLC_MONETARY=pl_PL.UTF-8\r\nLC_MESSAGES=\"en_US.UTF-8\"\r\nLC_PAPER=pl_PL.UTF-8\r\nLC_NAME=pl_PL.UTF-8\r\nLC_ADDRESS=pl_PL.UTF-8\r\nLC_TELEPHONE=pl_PL.UTF-8\r\nLC_MEASUREMENT=pl_PL.UTF-8\r\nLC_IDENTIFICATION=pl_PL.UTF-8\r\nLC_ALL=\r\n\r\n* Cursive version (from crates.io, from git, ...)\r\nversion = \"0.9.0-alpha.0\"\r\n"},"comment":{"url":"https://api.github.com/repos/gyscos/Cursive/issues/comments/379822479","html_url":"https://github.com/gyscos/Cursive/issues/231#issuecomment-379822479","issue_url":"https://api.github.com/repos/gyscos/Cursive/issues/231","id":379822479,"user":{"login":"xliiv","id":298994,"avatar_url":"https://avatars3.githubusercontent.com/u/298994?v=4","gravatar_id":"","url":"https://api.github.com/users/xliiv","html_url":"https://github.com/xliiv","followers_url":"https://api.github.com/users/xliiv/followers","following_url":"https://api.github.com/users/xliiv/following{/other_user}","gists_url":"https://api.github.com/users/xliiv/gists{/gist_id}","starred_url":"https://api.github.com/users/xliiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xliiv/subscriptions","organizations_url":"https://api.github.com/users/xliiv/orgs","repos_url":"https://api.github.com/users/xliiv/repos","events_url":"https://api.github.com/users/xliiv/events{/privacy}","received_events_url":"https://api.github.com/users/xliiv/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T17:01:28Z","updated_at":"2018-04-09T17:01:28Z","author_association":"CONTRIBUTOR","body":"Noooooooooooooooooooooo, i love it :)"}}
{"actor":{"display_login":"xliiv"}}