You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed a possible panic due to inconsistency between documentation and code implementation in cursive-main/cursive-core/src/views/linear_layout.rs. The details can be found in the following code. The code does not check whether i is out of bounds before use it directly.
/// Panics if `i >= self.len()`.pubfnset_weight(&mutself,i:usize,weight:usize){self.children[i]._weight = weight;}
The similar situation can be found in cursive-main/cursive-core/src/views/list_view.rs
/// Panics if `id >= self.len()`.pubfnrow_mut(&mutself,id:usize) -> &mutListChild{&mutself.children[id]}
Besides I think this documentation in cursive-main/cursive-core/src/views/linear_layout.rs is not complete, which should be "Panics if i >= self.len()" instead of "Panics if i > self.len()"
/// Panics if `i > self.len()`.pubfninsert_child<V:IntoBoxedView + 'static>(&mutself,i:usize,view:V){self.children.insert(
i,Child{view: view.into_boxed_view(),required_size:Vec2::zero(),last_size:Vec2::zero(),_weight:0,},);self.invalidate();}
The text was updated successfully, but these errors were encountered:
The code does not check whether i is out of bounds before use it directly.
self.children[i] is guaranteed to panic first here, so we just document this panic case.
For insert_child:
should be "Panics if i >= self.len()" instead of "Panics if i > self.len()"
Insertion at the end of the list is actually possible - it's effectively appending the entry to the list. This is why self.children.insert(i, ...) only panics if i > self.children.len().
I noticed a possible panic due to inconsistency between documentation and code implementation in cursive-main/cursive-core/src/views/linear_layout.rs. The details can be found in the following code. The code does not check whether i is out of bounds before use it directly.
The similar situation can be found in cursive-main/cursive-core/src/views/list_view.rs
Besides I think this documentation in cursive-main/cursive-core/src/views/linear_layout.rs is not complete, which should be "Panics if
i >= self.len()
" instead of "Panics ifi > self.len()
"The text was updated successfully, but these errors were encountered: