mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
Use thiserror for error handling with less boilerplate
This commit is contained in:
@@ -169,7 +169,7 @@ impl BitArray {
|
||||
pub fn setRange(&mut self, start: usize, end: usize) -> Result<()> {
|
||||
let mut end = end;
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::illegalArgument);
|
||||
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||
}
|
||||
if end == start {
|
||||
return Ok(());
|
||||
@@ -212,7 +212,7 @@ impl BitArray {
|
||||
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool> {
|
||||
let mut end = end;
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::illegalArgument);
|
||||
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||
}
|
||||
if end == start {
|
||||
return Ok(true); // empty range matches
|
||||
@@ -254,7 +254,7 @@ impl BitArray {
|
||||
*/
|
||||
pub fn appendBits(&mut self, value: u32, num_bits: usize) -> Result<()> {
|
||||
if num_bits > 32 {
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
return Err(Exceptions::illegal_argument_with(
|
||||
"num bits must be between 0 and 32",
|
||||
));
|
||||
}
|
||||
@@ -287,7 +287,7 @@ impl BitArray {
|
||||
|
||||
pub fn xor(&mut self, other: &BitArray) -> Result<()> {
|
||||
if self.size != other.size {
|
||||
return Err(Exceptions::illegalArgumentWith("Sizes don't match"));
|
||||
return Err(Exceptions::illegal_argument_with("Sizes don't match"));
|
||||
}
|
||||
for i in 0..self.bits.len() {
|
||||
//for (int i = 0; i < bits.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user