Skip to content

Commit

Permalink
Run cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrswastik-robot committed Dec 25, 2024
1 parent c3a91a6 commit c873193
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
22 changes: 5 additions & 17 deletions src/rust/lib_ccxr/src/common/bitstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> Bitstream<'a> {
let mut res = 0u64;
let mut bits_to_read = bnum;

if vbit < 1 || vbit > 8 {
if !(1..=8).contains(&vbit) {
return Err(BitstreamError::IllegalBitPosition(vbit));
}

Expand Down Expand Up @@ -280,10 +280,7 @@ pub extern "C" fn ccxr_next_bits(bs: *mut Bitstream<'static>, bnum: u32) -> u64
return 0;
}
unsafe {
match (*bs).next_bits(bnum) {
Ok(val) => val,
Err(_) => 0,
}
(*bs).next_bits(bnum).unwrap_or_default()
}
}

Expand All @@ -293,10 +290,7 @@ pub extern "C" fn ccxr_read_bits(bs: *mut Bitstream<'static>, bnum: u32) -> u64
return 0;
}
unsafe {
match (*bs).read_bits(bnum) {
Ok(val) => val,
Err(_) => 0,
}
(*bs).read_bits(bnum).unwrap_or_default()
}
}

Expand Down Expand Up @@ -369,10 +363,7 @@ pub extern "C" fn ccxr_read_exp_golomb_unsigned(bs: *mut Bitstream<'static>) ->
return 0;
}
unsafe {
match (*bs).read_exp_golomb_unsigned() {
Ok(val) => val,
Err(_) => 0,
}
(*bs).read_exp_golomb_unsigned().unwrap_or_default()
}
}

Expand All @@ -382,10 +373,7 @@ pub extern "C" fn ccxr_read_exp_golomb(bs: *mut Bitstream<'static>) -> i64 {
return 0;
}
unsafe {
match (*bs).read_exp_golomb() {
Ok(val) => val,
Err(_) => 0,
}
(*bs).read_exp_golomb().unwrap_or_default()
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/rust/lib_ccxr/src/util/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ mod tests {

#[test]
fn test_get_parity() {
assert_eq!(get_parity(0), false);
assert_eq!(get_parity(1), true);
assert_eq!(get_parity(128), true);
assert_eq!(get_parity(255), false);
assert!(!get_parity(0));
assert!(get_parity(1));
assert!(get_parity(128));
assert!(!get_parity(255));
}

#[test]
Expand Down

0 comments on commit c873193

Please sign in to comment.