Skip to content

Commit

Permalink
chore: various cleanups, version bump 0.4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimke committed Dec 28, 2023
1 parent c935940 commit 84a54d4
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rxing"
version = "0.4.11"
version = "0.4.12"
description="A rust port of the zxing barcode library."
license="Apache-2.0"
repository="https://github.com/rxing-core/rxing"
Expand Down
6 changes: 3 additions & 3 deletions src/client/result/VCardResultParser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ pub fn matchSingleVCardPrefixedField(
if values.is_empty() {
return None;
}
Some(values.get(0)?.clone())
Some(values.first()?.clone())
// return values == null || values.isEmpty() ? null : values.get(0);
}

Expand All @@ -437,7 +437,7 @@ fn toPrimaryValue(list: Option<Vec<String>>) -> String {
if l.is_empty() {
String::default()
} else {
l.get(0).unwrap_or(&String::default()).clone()
l.first().unwrap_or(&String::default()).clone()
}
} else {
String::default()
Expand Down Expand Up @@ -471,7 +471,7 @@ fn toTypes(lists: Option<Vec<Vec<String>>>) -> Vec<String> {
let mut result = Vec::with_capacity(local_lists.len()); //new ArrayList<>(lists.size());
for list in local_lists {
// for (List<String> list : lists) {
if let Some(value) = list.get(0) {
if let Some(value) = list.first() {
if !value.is_empty() {
let mut v_type = String::new();
let final_value = list.last().unwrap_or(&String::default()).clone();
Expand Down
2 changes: 1 addition & 1 deletion src/client/result/VEventResultParser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn matchVCardPrefixedField(prefix: &str, rawText: &str) -> Vec<String> {
for (i, res) in result.iter_mut().enumerate().take(size) {
// for i in 0..size {
// for (int i = 0; i < size; i++) {
*res = values.get(i).unwrap().get(0).unwrap().clone();
*res = values.get(i).unwrap().first().unwrap().clone();
}
result
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/minimal_eci_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ struct InputEdge {
cachedTotalSize: usize,
}
impl InputEdge {
const FNC1_UNICODE: &str = "\u{1000}";
const FNC1_UNICODE: &'static str = "\u{1000}";

pub fn new(
c: &str,
Expand Down
2 changes: 1 addition & 1 deletion src/common/reedsolomon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn get_predefined_genericgf(request: PredefinedGenericGF) -> GenericGFRef {
PredefinedGenericGF::DataMatrixField256 | PredefinedGenericGF::AztecData8 => {
&DATA_MATRIX_FIELD_256
} // x^8 + x^5 + x^3 + x^2 + 1
// PredefinedGenericGF::PDF417 => &PDF_417_FIELD,
// PredefinedGenericGF::PDF417 => &PDF_417_FIELD,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/oned/code_39_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl OneDReader for Code39Reader {
}
}
impl Code39Reader {
pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";

/**
* These represent the encodings of characters, as patterns of wide and narrow bars.
Expand Down
2 changes: 1 addition & 1 deletion src/oned/code_93_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl OneDReader for Code93Reader {

impl Code93Reader {
// Note that 'abcd' are dummy characters in place of control characters.
pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
pub const ALPHABET: [char; 48] = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
Expand Down
2 changes: 1 addition & 1 deletion src/oned/rss/expanded/bit_array_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn buildBitArray(pairs: &Vec<ExpandedPair>) -> Option<BitArray> {
let mut binary = BitArray::with_size(size);
let mut accPos = 0;

let firstPair = pairs.get(0)?;
let firstPair = pairs.first()?;
let rp = firstPair.getRightChar().as_ref()?;
let firstValue = rp.getValue();
let mut i = 11;
Expand Down
4 changes: 2 additions & 2 deletions src/oned/rss/expanded/rss_expanded_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl RSSExpandedReader {
let resultingString = decoder.parseInformation()?;

let firstPoints = pairs
.get(0)
.first()
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
.getFinderPattern()
.as_ref()
Expand Down Expand Up @@ -565,7 +565,7 @@ impl RSSExpandedReader {
}

fn checkChecksum(&self) -> bool {
let Some(firstPair) = self.pairs.get(0) else {
let Some(firstPair) = self.pairs.first() else {
return false;
};
let checkCharacter = firstPair.getLeftChar();
Expand Down
6 changes: 2 additions & 4 deletions src/qrcode/cpp_port/bitmatrix_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ pub fn ReadQRCodewords(
) -> Result<Vec<u8>> {
let functionPattern: BitMatrix = version.buildFunctionPattern()?;

let mut result = Vec::new();
result.reserve(version.getTotalCodewords() as usize);
let mut result = Vec::with_capacity(version.getTotalCodewords() as usize);
let mut currentByte = 0;
let mut readingUp = true;
let mut bitsRead = 0;
Expand Down Expand Up @@ -190,8 +189,7 @@ pub fn ReadMQRCodewords(
9
};

let mut result = Vec::new();
result.reserve(version.getTotalCodewords() as usize);
let mut result = Vec::with_capacity(version.getTotalCodewords() as usize);
let mut currentByte = 0;
let mut readingUp = true;
let mut bitsRead = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/qrcode/detector/alignment_pattern_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl AlignmentPatternFinder {
if !self.possibleCenters.is_empty() {
Ok(*(self
.possibleCenters
.get(0)
.first()
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS))?)
} else {
Err(Exceptions::NOT_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions src/qrcode/encoder/minimal_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ impl RXingResultList {
// prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI.
// If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1)
if isGS1 {
if let Some(first) = list.get(0) {
if let Some(first) = list.first() {
if first.mode != Mode::ECI && containsECI {
// prepend a default character set ECI
list.push(RXingResultNode::new(
Expand All @@ -769,7 +769,7 @@ impl RXingResultList {
}
}

if let Some(first) = list.get(0) {
if let Some(first) = list.first() {
// prepend or insert a FNC1_FIRST_POSITION after the ECI (if any)
if first.mode != Mode::ECI {
//&& containsECI {
Expand Down

0 comments on commit 84a54d4

Please sign in to comment.