Edit refcell_view example to use find_id

This commit is contained in:
Alexandre Bury 2017-02-26 16:01:23 -08:00
parent 23b0f9c168
commit 30f13fc260

View File

@ -28,12 +28,12 @@ fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) {
// Get handles for each view. // Get handles for each view.
let edit_1 = siv.find_id_mut::<EditView>("1").unwrap(); let edit_1 = siv.find_id_mut::<EditView>("1").unwrap();
let edit_2 = siv.find_id_mut::<EditView>("2").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. // 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" "match"
} else { } else {
"no match" "no match"
}); }));
} }