-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Steps to reproduce
- Apply this diff to basic example
diff --git a/examples/basic.rs b/examples/basic.rs
index 677bb81..5969863 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -100,22 +100,20 @@ fn main() {
});
table.set_on_submit(|siv: &mut Cursive, row: usize, index: usize| {
- let value = siv
- .call_on_name("table", move |table: &mut TableView<Foo, BasicColumn>| {
- format!("{:?}", table.borrow_item(index).unwrap())
+ siv.call_on_name("table", move |table: &mut TableView<Foo, BasicColumn>| {
+ let mut items = Vec::new();
+ let mut rng = rand::thread_rng();
+ for i in 0..49 {
+ items.push(Foo {
+ name: format!("Name {}", i),
+ count: rng.gen_range(0, 255),
+ rate: rng.gen_range(0, 255),
+ });
+ }
+
+ table.set_items(items);
})
.unwrap();
-
- siv.add_layer(
- Dialog::around(TextView::new(value))
- .title(format!("Removing row # {}", row))
- .button("Close", move |s| {
- s.call_on_name("table", |table: &mut TableView<Foo, BasicColumn>| {
- table.remove_item(index);
- });
- s.pop_layer();
- }),
- );
});
siv.add_layer(Dialog::around(table.with_name("table").min_size((50, 20))).title("Table View"));
- Run (redirect output to log file)
- Scroll to last item and submit on it
In the log file you will see
thread 'main' panicked at 'index out of bounds: the len is 49 but the index is 49', /tmp/cursive_table_view/src/lib.rs:486:18
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels