Update macro and cargo fmt

This commit is contained in:
Steve Cook
2023-03-01 13:43:21 -05:00
parent 51fcc98b34
commit b561bd77c3
19 changed files with 101 additions and 64 deletions

View File

@@ -79,7 +79,8 @@ impl Encoder for Base256Encoder {
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
buffer.insert(
ci_pos,
char::from_u32(dataCount as u32 % 250).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
char::from_u32(dataCount as u32 % 250)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
);
} else {
return Err(Exceptions::illegal_state_with(format!(
@@ -92,7 +93,10 @@ impl Encoder for Base256Encoder {
// for (int i = 0, c = buffer.length(); i < c; i++) {
context.writeCodeword(
Self::randomize255State(
buffer.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
buffer
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
context.getCodewordCount() as u32 + 1,
)
.ok_or(Exceptions::PARSE)? as u8,

View File

@@ -183,9 +183,7 @@ impl C40Encoder {
context: &mut EncoderContext,
buffer: &mut String,
) -> Result<()> {
context.writeCodewords(
&Self::encodeToCodewords(buffer).ok_or(Exceptions::FORMAT)?,
);
context.writeCodewords(&Self::encodeToCodewords(buffer).ok_or(Exceptions::FORMAT)?);
buffer.replace_range(0..3, "");
// buffer.delete(0, 3);
Ok(())