Edit refcell_view example to use `find_id`
@@ -28,12 +28,12 @@ fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) {
// Get handles for each view.
let edit_1 = siv.find_id_mut::<EditView>("1").unwrap();
let edit_2 = siv.find_id_mut::<EditView>("2").unwrap();
- let mut text = siv.find_id_mut::<TextView>("match").unwrap();
// Directly compare references to edit_1 and edit_2.
- text.set_content(if edit_1.get_content() == edit_2.get_content() {
+ let matches = edit_1.get_content() == edit_2.get_content();
+ siv.find_id("match", |v: &mut TextView| v.set_content(if matches {
"match"
} else {
"no match"
- });
+ }));
}
