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 in im-rs/src/vector/mod.rs. Although the documentation mentioned it will panic if the index is out of bounds, the code does not check whether index is out of bounds before using it as out[index], self[index]. So I think the code should check it before(using get()).
/// Panics if the index is out of bounds.////// Time: O(log n)////// # Examples////// ```/// # #[macro_use] extern crate im;/// # use im::Vector;/// let mut vec = vector![1, 2, 3];/// assert_eq!(vector![1, 5, 3], vec.update(1, 5));/// ```#[must_use]pubfnupdate(&self,index:usize,value:A) -> Self{letmut out = self.clone();
out[index] = value;
out
}/// Update the value at index `index` in a vector.////// Returns the previous value at the index.////// Panics if the index is out of bounds.////// Time: O(log n)#[inline]pubfnset(&mutself,index:usize,value:A) -> A{replace(&mutself[index], value)}
The text was updated successfully, but these errors were encountered:
I noticed a possible panic in im-rs/src/vector/mod.rs. Although the documentation mentioned it will panic if the index is out of bounds, the code does not check whether index is out of bounds before using it as out[index], self[index]. So I think the code should check it before(using get()).
The text was updated successfully, but these errors were encountered: