Skip to content

Commit

Permalink
remove redendant code + 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
malik672 committed Jan 11, 2024
1 parent 0a1fb03 commit 686d223
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

#[derive(Debug, Error)]
pub enum Error {

#[error("Chain IDs do not match: {0} and {1}")]
ChainIdMismatch(u32, u32),

Expand Down
14 changes: 9 additions & 5 deletions src/utils/sorted_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ pub fn sorted_insert<T: Clone>(
comparator: fn(&T, &T) -> Ordering,
) -> Result<Option<T>, Error> {
if max_size == 0 {
return Err(Error::Incorrect("max_size can't be equals to zero".to_owned()));
return Err(Error::Incorrect(
"max_size can't be equals to zero".to_owned(),
));
}

if items.len() > max_size {
return Err(Error::Incorrect("items_size has to greater than max_size".to_string()));
return Err(Error::Incorrect(
"items_size has to greater than max_size".to_string(),
));
}

let removed_item = if items.len() == max_size {
Expand Down Expand Up @@ -47,18 +51,18 @@ mod tests {
}

#[test]
#[should_panic(expected = "MAX_SIZE_ZERO")]
#[should_panic(expected = "max_size can't be equals to zero")]
fn test_max_size_zero() {
let mut arr = Vec::new();
sorted_insert(&mut arr, 1, 0, cmp).unwrap();
}

#[test]
#[should_panic(expected = "ITEMS_SIZE")]
#[should_panic(expected = "items_size has to greater than max_size")]
fn test_length_greater_than_max_size() {
let mut arr = vec![1, 2];
let _w = sorted_insert(&mut arr, 1, 1, cmp).unwrap();
assert!(_w.is_none(), "ITEMS_SIZE");
assert!(_w.is_none(), "items_size has to greater than max_size");
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion src/utils/sqrt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::prelude::*;
///
pub fn sqrt(value: &BigInt) -> Result<BigInt, Error> {
if !value >= Zero::zero() {
return Err(Error::Incorrect("value has to be greater than -1".to_string()));
return Err(Error::Incorrect(
"value has to be greater than -1".to_string(),
));
}

// If the value is less than or equal to MAX_SAFE_INTEGER,
Expand Down

0 comments on commit 686d223

Please sign in to comment.