standardize empty string to String::default()

This replaces "".to_owned() "".to_string() and String::from("")
This commit is contained in:
Henry Schimke
2023-02-04 13:13:05 -06:00
parent ae7562af28
commit 92f15be032
26 changed files with 102 additions and 108 deletions

View File

@@ -62,18 +62,18 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
Vec::new() Vec::new()
}, },
Vec::new(), Vec::new(),
pronunciation.unwrap_or_default(), //"".to_owned(), pronunciation.unwrap_or_default(),
phoneNumbers, phoneNumbers,
Vec::new(), Vec::new(),
emails, //Vec::new(), emails, //Vec::new(),
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
note, note,
addresses, addresses,
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
Vec::new(), Vec::new(),
Vec::new(), Vec::new(),
) { ) {

View File

@@ -61,7 +61,7 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
.unwrap_or_default(); .unwrap_or_default();
if !ResultParser::isStringOfDigits(&birthday, 8) { if !ResultParser::isStringOfDigits(&birthday, 8) {
// No reason to throw out the whole card because the birthday is formatted wrong. // No reason to throw out the whole card because the birthday is formatted wrong.
birthday = "".to_owned(); birthday = String::default();
} }
let urls = ResultParser::match_do_co_mo_prefixed_field("URL:", &rawText).unwrap_or_default(); let urls = ResultParser::match_do_co_mo_prefixed_field("URL:", &rawText).unwrap_or_default();
@@ -78,13 +78,13 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
Vec::new(), Vec::new(),
emails, emails,
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
note, note,
addresses, addresses,
Vec::new(), Vec::new(),
org, org,
birthday, birthday,
"".to_owned(), String::default(),
urls, urls,
Vec::new(), Vec::new(),
) { ) {

View File

@@ -83,18 +83,18 @@ impl AddressBookParsedRXingResult {
Self::with_details( Self::with_details(
names, names,
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
phone_numbers, phone_numbers,
phone_types, phone_types,
emails, emails,
email_types, email_types,
"".to_owned(), String::default(),
"".to_owned(), String::default(),
addresses, addresses,
address_types, address_types,
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
Vec::new(), Vec::new(),
Vec::new(), Vec::new(),
) )

View File

@@ -63,17 +63,17 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
if let Ok(adb) = AddressBookParsedRXingResult::with_details( if let Ok(adb) = AddressBookParsedRXingResult::with_details(
ResultParser::maybeWrap(Some(fullName))?, ResultParser::maybeWrap(Some(fullName))?,
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3), buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3),
Vec::new(), Vec::new(),
ResultParser::maybeWrap(Some(email))?, ResultParser::maybeWrap(Some(email))?,
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
addresses?, addresses?,
Vec::new(), Vec::new(),
org, org,
"".to_owned(), String::default(),
title, title,
Vec::new(), Vec::new(),
Vec::new(), Vec::new(),

View File

@@ -37,7 +37,7 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
if URIResultParser::is_basically_valid_uri(&uri) { if URIResultParser::is_basically_valid_uri(&uri) {
Some(ParsedClientResult::URIResult(URIParsedRXingResult::new( Some(ParsedClientResult::URIResult(URIParsedRXingResult::new(
uri, uri,
title.unwrap_or_else(|| "".to_owned()), title.unwrap_or_else(|| String::default()),
))) )))
} else { } else {
None None

View File

@@ -244,7 +244,7 @@ impl CalendarParsedRXingResult {
fn format_event(allDay: bool, date: i64) -> String { fn format_event(allDay: bool, date: i64) -> String {
if date < 0 { if date < 0 {
return "".to_owned(); return String::default();
} }
let format_string = if allDay { "%F" } else { "%c" }; let format_string = if allDay { "%F" } else { "%c" };
// DateFormat format = allDay // DateFormat format = allDay
@@ -254,7 +254,7 @@ impl CalendarParsedRXingResult {
if let Some(dtm) = NaiveDateTime::from_timestamp_opt(date, 0) { if let Some(dtm) = NaiveDateTime::from_timestamp_opt(date, 0) {
dtm.format(format_string).to_string() dtm.format(format_string).to_string()
} else { } else {
String::from("") String::default()
} }
} }

View File

@@ -225,7 +225,7 @@ fn doTest(
assert_eq!( assert_eq!(
endString, endString,
if calRXingResult.getEndTimestamp() < 0i64 { if calRXingResult.getEndTimestamp() < 0i64 {
"".to_owned() String::default()
} else { } else {
format_date_string(calRXingResult.getEndTimestamp(), dateFormat) format_date_string(calRXingResult.getEndTimestamp(), dateFormat)
// dateFormat.format(calRXingResult.getEndTimestamp()) // dateFormat.format(calRXingResult.getEndTimestamp())
@@ -253,7 +253,7 @@ fn format_date_string(timestamp: i64, format_string: &str) -> String {
if let Some(dtm) = NaiveDateTime::from_timestamp_opt(timestamp, 0) { if let Some(dtm) = NaiveDateTime::from_timestamp_opt(timestamp, 0) {
dtm.format(format_string).to_string() dtm.format(format_string).to_string()
} else { } else {
String::from("") String::default()
} }
// DateTime::from(timestamp,0).with_timezone(Utc).format(format_string).to_string() // DateTime::from(timestamp,0).with_timezone(Utc).format(format_string).to_string()
} }

View File

@@ -55,8 +55,8 @@ impl EmailAddressParsedRXingResult {
vec![to], vec![to],
Vec::new(), Vec::new(),
Vec::new(), Vec::new(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
) )
} }

View File

@@ -79,8 +79,8 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
let nameValues = ResultParser::parseNameValuePairs(&rawText); let nameValues = ResultParser::parseNameValuePairs(&rawText);
let mut ccs: Vec<String> = Vec::new(); let mut ccs: Vec<String> = Vec::new();
let mut bccs: Vec<String> = Vec::new(); let mut bccs: Vec<String> = Vec::new();
let mut subject = "".to_owned(); let mut subject = String::default();
let mut body = "".to_owned(); let mut body = String::default();
if let Some(nv) = nameValues { if let Some(nv) = nameValues {
// if (nameValues != null) { // if (nameValues != null) {
if tos.is_empty() { if tos.is_empty() {
@@ -115,8 +115,8 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
// if bccString != null { // if bccString != null {
// bccs = COMMA.split(bccString); // bccs = COMMA.split(bccString);
// } // }
subject = nv.get("subject").unwrap_or(&"".to_owned()).clone(); subject = nv.get("subject").unwrap_or(&String::default()).clone();
body = nv.get("body").unwrap_or(&"".to_owned()).clone(); body = nv.get("body").unwrap_or(&String::default()).clone();
} }
Some(ParsedClientResult::EmailResult( Some(ParsedClientResult::EmailResult(
EmailAddressParsedRXingResult::with_details(tos, ccs, bccs, subject, body), EmailAddressParsedRXingResult::with_details(tos, ccs, bccs, subject, body),

View File

@@ -52,19 +52,19 @@ pub fn parse(result: &crate::RXingResult) -> Option<super::ParsedClientResult> {
} }
let rawText = ResultParser::getMassagedText(result); let rawText = ResultParser::getMassagedText(result);
let mut productID: String = "".to_owned(); // = null; let mut productID: String = String::default(); // = null;
let mut sscc: String = "".to_owned(); let mut sscc: String = String::default();
let mut lotNumber: String = "".to_owned(); let mut lotNumber: String = String::default();
let mut productionDate: String = "".to_owned(); let mut productionDate: String = String::default();
let mut packagingDate: String = "".to_owned(); let mut packagingDate: String = String::default();
let mut bestBeforeDate: String = "".to_owned(); let mut bestBeforeDate: String = String::default();
let mut expirationDate: String = "".to_owned(); let mut expirationDate: String = String::default();
let mut weight: String = "".to_owned(); let mut weight: String = String::default();
let mut weightType: String = "".to_owned(); let mut weightType: String = String::default();
let mut weightIncrement: String = "".to_owned(); let mut weightIncrement: String = String::default();
let mut price: String = "".to_owned(); let mut price: String = String::default();
let mut priceIncrement: String = "".to_owned(); let mut priceIncrement: String = String::default();
let mut priceCurrency: String = "".to_owned(); let mut priceCurrency: String = String::default();
let mut uncommonAIs = HashMap::new(); let mut uncommonAIs = HashMap::new();
let mut i = 0; let mut i = 0;

View File

@@ -503,7 +503,7 @@ fn format_date(year: i32, month: u32, day: u32) -> String {
if let LocalResult::Single(dtm) = Utc.with_ymd_and_hms(year, month, day, 0, 0, 0) { if let LocalResult::Single(dtm) = Utc.with_ymd_and_hms(year, month, day, 0, 0, 0) {
dtm.format("%F").to_string() dtm.format("%F").to_string()
} else { } else {
String::from("") String::default()
} }
// Calendar cal = Calendar.getInstance(); // Calendar cal = Calendar.getInstance();
// cal.clear(); // cal.clear();
@@ -517,7 +517,7 @@ fn format_time(year: i32, month: u32, day: u32, hour: u32, min: u32, sec: u32) -
dtm.format("%c").to_string() dtm.format("%c").to_string()
} else { } else {
String::from("") String::default()
} }
// Calendar cal = Calendar.getInstance(); // Calendar cal = Calendar.getInstance();
// cal.clear(); // cal.clear();

View File

@@ -167,7 +167,7 @@ pub fn parseRXingResult(the_rxing_result: &RXingResult) -> ParsedClientResult {
ParsedClientResult::TextResult(TextParsedRXingResult::new( ParsedClientResult::TextResult(TextParsedRXingResult::new(
the_rxing_result.getText().to_owned(), the_rxing_result.getText().to_owned(),
"".to_owned(), String::default(),
)) ))
} }
@@ -284,7 +284,7 @@ pub fn appendKeyValue(keyValue: &str, result: &mut HashMap<String, String>) {
let kvp: Vec<&str> = keyValueTokens.take(2).collect(); let kvp: Vec<&str> = keyValueTokens.take(2).collect();
if let [key, value] = kvp[..] { if let [key, value] = kvp[..] {
let p_value = urlDecode(value).unwrap_or_else(|_| "".to_owned()); let p_value = urlDecode(value).unwrap_or_else(|_| String::default());
result.insert(key.to_owned(), p_value); result.insert(key.to_owned(), p_value);
} }

View File

@@ -54,15 +54,15 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
return None; return None;
} }
let mut subject = "".to_owned(); let mut subject = String::default();
let mut body = "".to_owned(); let mut body = String::default();
let mut querySyntax = false; let mut querySyntax = false;
// Check up front if this is a URI syntax string with query arguments // Check up front if this is a URI syntax string with query arguments
if let Some(name_value_pairs) = ResultParser::parseNameValuePairs(&raw_text) { if let Some(name_value_pairs) = ResultParser::parseNameValuePairs(&raw_text) {
if !name_value_pairs.is_empty() { if !name_value_pairs.is_empty() {
subject = String::from(name_value_pairs.get("subject").unwrap_or(&"".to_owned())); subject = String::from(name_value_pairs.get("subject").unwrap_or(&String::default()));
body = String::from(name_value_pairs.get("body").unwrap_or(&"".to_owned())); body = String::from(name_value_pairs.get("body").unwrap_or(&String::default()));
querySyntax = true; querySyntax = true;
} }
} }
@@ -130,7 +130,7 @@ fn add_number_via(numbers: &mut Vec<String>, vias: &mut Vec<String>, number_part
} }
} else { } else {
numbers.push(number_part.to_owned()); numbers.push(number_part.to_owned());
//vias.push("".to_owned()); //vias.push(String::default());
} }
} }

View File

@@ -57,8 +57,8 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
Some(ParsedClientResult::SMSResult( Some(ParsedClientResult::SMSResult(
SMSParsedRXingResult::with_singles( SMSParsedRXingResult::with_singles(
number.to_owned(), number.to_owned(),
String::from(""), String::default(),
String::from(""), String::default(),
body.to_owned(), body.to_owned(),
), ),
)) ))

View File

@@ -51,7 +51,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<ParsedClientResult>
Some(ParsedClientResult::TelResult(TelParsedRXingResult::new( Some(ParsedClientResult::TelResult(TelParsedRXingResult::new(
number.to_owned(), number.to_owned(),
telURI, telURI,
"".to_owned(), String::default(),
))) )))
} }
// } // }

View File

@@ -59,7 +59,7 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
if raw_text.starts_with("URL:") || raw_text.starts_with("URI:") { if raw_text.starts_with("URL:") || raw_text.starts_with("URI:") {
return Some(ParsedClientResult::URIResult(URIParsedRXingResult::new( return Some(ParsedClientResult::URIResult(URIParsedRXingResult::new(
raw_text[4..].trim().to_owned(), raw_text[4..].trim().to_owned(),
"".to_owned(), String::default(),
))); )));
// return new URIParsedRXingResult(rawText.substring(4).trim(), null); // return new URIParsedRXingResult(rawText.substring(4).trim(), null);
} }
@@ -69,7 +69,7 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
} }
Some(ParsedClientResult::URIResult(URIParsedRXingResult::new( Some(ParsedClientResult::URIResult(URIParsedRXingResult::new(
raw_text.to_owned(), raw_text.to_owned(),
"".to_owned(), String::default(),
))) )))
} }

View File

@@ -116,10 +116,10 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
if isLikeVCardDate(&bday_array[0]) { if isLikeVCardDate(&bday_array[0]) {
bday_array bday_array
} else { } else {
vec!["".to_owned()] vec![String::default()]
} }
} else { } else {
vec!["".to_owned()] vec![String::default()]
}; };
// if birthday != null && !isLikeVCardDate(birthday.get(0)) { // if birthday != null && !isLikeVCardDate(birthday.get(0)) {
// birthday = null; // birthday = null;
@@ -143,7 +143,7 @@ pub fn parse(result: &RXingResult) -> Option<ParsedClientResult> {
if let Ok(adb) = AddressBookParsedRXingResult::with_details( if let Ok(adb) = AddressBookParsedRXingResult::with_details(
toPrimaryValues(Some(names)), toPrimaryValues(Some(names)),
nicknames, nicknames,
"".to_owned(), String::default(),
toPrimaryValues(phoneNumbers.clone()), toPrimaryValues(phoneNumbers.clone()),
toTypes(phoneNumbers), toTypes(phoneNumbers),
toPrimaryValues(emails.clone()), toPrimaryValues(emails.clone()),
@@ -416,7 +416,7 @@ fn maybeAppendFragment(fragmentBuffer: &mut Vec<u8>, charset: &str, result: &mut
let fragmentBytes = fragmentBuffer.clone(); let fragmentBytes = fragmentBuffer.clone();
let fragment; let fragment;
if charset.is_empty() { if charset.is_empty() {
fragment = String::from_utf8(fragmentBytes).unwrap_or_else(|_| "".to_owned()); fragment = String::from_utf8(fragmentBytes).unwrap_or_else(|_| String::default());
// fragment = new String(fragmentBytes, StandardCharsets.UTF_8); // fragment = new String(fragmentBytes, StandardCharsets.UTF_8);
} else if let Some(enc) = encoding::label::encoding_from_whatwg_label(charset) { } else if let Some(enc) = encoding::label::encoding_from_whatwg_label(charset) {
fragment = if let Ok(encoded_result) = fragment = if let Ok(encoded_result) =
@@ -424,10 +424,10 @@ fn maybeAppendFragment(fragmentBuffer: &mut Vec<u8>, charset: &str, result: &mut
{ {
encoded_result encoded_result
} else { } else {
String::from_utf8(fragmentBytes).unwrap_or_else(|_| "".to_owned()) String::from_utf8(fragmentBytes).unwrap_or_else(|_| String::default())
} }
} else { } else {
fragment = String::from_utf8(fragmentBytes).unwrap_or_else(|_| "".to_owned()) fragment = String::from_utf8(fragmentBytes).unwrap_or_else(|_| String::default())
} }
fragmentBuffer.clear(); fragmentBuffer.clear();
result.push_str(&fragment); result.push_str(&fragment);
@@ -451,19 +451,13 @@ pub fn matchSingleVCardPrefixedField(
fn toPrimaryValue(list: Option<Vec<String>>) -> String { fn toPrimaryValue(list: Option<Vec<String>>) -> String {
if let Some(l) = list { if let Some(l) = list {
if l.is_empty() { if l.is_empty() {
"".to_owned() String::default()
} else { } else {
l.get(0).unwrap_or(&"".to_owned()).clone() l.get(0).unwrap_or(&String::default()).clone()
} }
} else { } else {
"".to_owned() String::default()
} }
// if list.is_empty() {
// "".to_owned()
// }else {
// *list.get(0).unwrap_or(&"".to_owned())
// }
// return list == null || list.isEmpty() ? null : list.get(0);
} }
fn toPrimaryValues(lists: Option<Vec<Vec<String>>>) -> Vec<String> { fn toPrimaryValues(lists: Option<Vec<Vec<String>>>) -> Vec<String> {
@@ -496,11 +490,11 @@ fn toTypes(lists: Option<Vec<Vec<String>>>) -> Vec<String> {
if let Some(value) = list.get(0) { if let Some(value) = list.get(0) {
if !value.is_empty() { if !value.is_empty() {
let mut v_type = String::new(); let mut v_type = String::new();
let final_value = list.last().unwrap_or(&"".to_owned()).clone(); let final_value = list.last().unwrap_or(&String::default()).clone();
if !final_value.is_empty() { if !final_value.is_empty() {
for i in 0..list.len() - 1 { for i in 0..list.len() - 1 {
// for (int i = 1; i < list.size(); i++) { // for (int i = 1; i < list.size(); i++) {
let metadatum = list.get(i).unwrap_or(&"".to_owned()).clone(); let metadatum = list.get(i).unwrap_or(&String::default()).clone();
if let Some(equals) = metadatum.find('=') { if let Some(equals) = metadatum.find('=') {
if "TYPE" == (metadatum[0..equals]).to_uppercase() { if "TYPE" == (metadatum[0..equals]).to_uppercase() {
v_type = metadatum[equals + 1..].to_owned(); v_type = metadatum[equals + 1..].to_owned();
@@ -544,12 +538,12 @@ fn formatNames(names: &mut Vec<Vec<String>>) {
for list in names { for list in names {
// for (List<String> list : names) { // for (List<String> list : names) {
let mut pos = 0; let mut pos = 0;
while let Some(_fnd) = list.get(pos).unwrap_or(&"".to_owned()).find('=') { while let Some(_fnd) = list.get(pos).unwrap_or(&String::default()).find('=') {
pos += 1; pos += 1;
} }
let name = list.get(pos).unwrap_or(&"".to_owned()).clone(); let name = list.get(pos).unwrap_or(&String::default()).clone();
let mut components = vec!["".to_owned(); 5]; let mut components = vec![String::default(); 5];
let mut start = 0; let mut start = 0;
let mut end = 0; let mut end = 0;
let mut componentIndex = 0; let mut componentIndex = 0;

View File

@@ -118,26 +118,26 @@ fn matchSingleVCardPrefixedField(prefix: &str, rawText: &str) -> String {
VCardResultParser::matchSingleVCardPrefixedField(prefix, rawText, true, false) VCardResultParser::matchSingleVCardPrefixedField(prefix, rawText, true, false)
{ {
if values.is_empty() { if values.is_empty() {
"".to_owned() String::default()
} else { } else {
let tz_mod = if values.len() > 1 { let tz_mod = if values.len() > 1 {
if let Some(v) = values.get(values.len() - 2) { if let Some(v) = values.get(values.len() - 2) {
if let Some(tz_loc) = v.find("TZID=") { if let Some(tz_loc) = v.find("TZID=") {
v[tz_loc + 5..].to_owned() v[tz_loc + 5..].to_owned()
} else { } else {
"".to_owned() String::default()
} }
} else { } else {
"".to_owned() String::default()
} }
} else { } else {
"".to_owned() String::default()
}; };
let root_time = values.last().unwrap().clone(); let root_time = values.last().unwrap().clone();
format!("{root_time}{tz_mod}") format!("{root_time}{tz_mod}")
} }
} else { } else {
"".to_owned() String::default()
} }
// return values == null || values.isEmpty() ? null : values.get(0); // return values == null || values.isEmpty() ? null : values.get(0);
} }
@@ -148,7 +148,7 @@ fn matchVCardPrefixedField(prefix: &str, rawText: &str) -> Vec<String> {
Vec::new() Vec::new()
} else { } else {
let size = values.len(); let size = values.len();
let mut result = vec!["".to_owned(); size]; //new String[size]; let mut result = vec![String::default(); size]; //new String[size];
for (i, res) in result.iter_mut().enumerate().take(size) { for (i, res) in result.iter_mut().enumerate().take(size) {
// for i in 0..size { // for i in 0..size {
// for (int i = 0; i < size; i++) { // for (int i = 0; i < size; i++) {

View File

@@ -67,10 +67,10 @@ impl WifiParsedRXingResult {
ssid, ssid,
password, password,
hidden, hidden,
String::from(""), String::default(),
String::from(""), String::default(),
String::from(""), String::default(),
String::from(""), String::default(),
) )
} }

View File

@@ -52,12 +52,12 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
} }
let rawText = rawText_unstripped[WIFI_TEST.len()..].to_owned(); let rawText = rawText_unstripped[WIFI_TEST.len()..].to_owned();
let ssid = ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false) let ssid = ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false)
.unwrap_or_else(|| String::from("")); .unwrap_or_else(|| String::default());
if ssid.is_empty() { if ssid.is_empty() {
return None; return None;
} }
let pass = ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false) let pass = ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false)
.unwrap_or_else(|| String::from("")); .unwrap_or_else(|| String::default());
let n_type = let n_type =
if let Some(nt) = ResultParser::matchSinglePrefixedField("T:", &rawText, ';', false) { if let Some(nt) = ResultParser::matchSinglePrefixedField("T:", &rawText, ';', false) {
nt nt
@@ -81,15 +81,15 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
} }
hv hv
} else { } else {
String::from("") String::default()
}; };
let identity = ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false) let identity = ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false)
.unwrap_or_else(|| String::from("")); .unwrap_or_else(|| String::default());
let anonymousIdentity = ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false) let anonymousIdentity = ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false)
.unwrap_or_else(|| String::from("")); .unwrap_or_else(|| String::default());
let eapMethod = ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false) let eapMethod = ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false)
.unwrap_or_else(|| String::from("")); .unwrap_or_else(|| String::default());
Some(ParsedClientResult::WiFiResult( Some(ParsedClientResult::WiFiResult(
WifiParsedRXingResult::with_details( WifiParsedRXingResult::with_details(
@@ -100,7 +100,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
identity, identity,
anonymousIdentity, anonymousIdentity,
eapMethod, eapMethod,
phase2Method.unwrap_or_else(|| String::from("")), phase2Method.unwrap_or_else(|| String::default()),
), ),
)) ))
} }

View File

@@ -139,7 +139,7 @@ static FOUR_DIGIT_DATA_LENGTH: Lazy<HashMap<String, DataLength>> = Lazy::new(||
pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String, Exceptions> { pub fn parseFieldsInGeneralPurpose(rawInformation: &str) -> Result<String, Exceptions> {
if rawInformation.is_empty() { if rawInformation.is_empty() {
return Ok("".to_owned()); return Ok(String::default());
} }
// Processing 2-digit AIs // Processing 2-digit AIs

View File

@@ -57,7 +57,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
) -> Result<String, Exceptions> { ) -> Result<String, Exceptions> {
let mut buff = buff; let mut buff = buff;
let mut currentPosition = initialPosition; let mut currentPosition = initialPosition;
let mut remaining = "".to_owned(); let mut remaining = String::default();
loop { loop {
let info = self.decodeGeneralPurposeField(currentPosition, &remaining)?; let info = self.decodeGeneralPurposeField(currentPosition, &remaining)?;
let parsedFields = field_parser::parseFieldsInGeneralPurpose(info.getNewString())?; let parsedFields = field_parser::parseFieldsInGeneralPurpose(info.getNewString())?;
@@ -67,7 +67,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
if info.isRemaining() { if info.isRemaining() {
remaining = info.getRemainingValue().to_string(); remaining = info.getRemainingValue().to_string();
} else { } else {
remaining = "".to_owned(); remaining = String::default();
} }
if currentPosition == info.getNewPosition() { if currentPosition == info.getNewPosition() {

View File

@@ -49,18 +49,18 @@ fn testDecodeRow2result2() {
let expected = ExpandedProductParsedRXingResult::new( let expected = ExpandedProductParsedRXingResult::new(
"(01)90012345678908(3103)001750".to_owned(), "(01)90012345678908(3103)001750".to_owned(),
"90012345678908".to_owned(), "90012345678908".to_owned(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"001750".to_owned(), "001750".to_owned(),
ExpandedProductParsedRXingResult::KILOGRAM.to_owned(), ExpandedProductParsedRXingResult::KILOGRAM.to_owned(),
"3".to_owned(), "3".to_owned(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
"".to_owned(), String::default(),
HashMap::new(), HashMap::new(),
); );

View File

@@ -476,7 +476,7 @@ fn generatePermutation(index: u32, length: u32, chars: &[char]) -> String {
baseNNumber.insert(0, '0'); baseNNumber.insert(0, '0');
// baseNNumber = "0" + baseNNumber; // baseNNumber = "0" + baseNNumber;
} }
let mut prefix = String::from(""); let mut prefix = String::default();
for ch in baseNNumber.chars() { for ch in baseNNumber.chars() {
prefix.push(chars[(ch as isize - '0' as isize) as usize]); prefix.push(chars[(ch as isize - '0' as isize) as usize]);
} }

View File

@@ -509,7 +509,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
read_to_string(&file).expect("ok") read_to_string(&file).expect("ok")
} }
} else { } else {
"".to_owned() String::default()
}; };
// let string_contents = read_to_string(&file)?; //new String(Files.readAllBytes(file), charset); // let string_contents = read_to_string(&file)?; //new String(Files.readAllBytes(file), charset);
if string_contents.ends_with('\n') { if string_contents.ends_with('\n') {

View File

@@ -651,7 +651,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
read_to_string(&file).expect("ok") read_to_string(&file).expect("ok")
} }
} else { } else {
"".to_owned() String::default()
}; };
// let string_contents = read_to_string(&file)?; //new String(Files.readAllBytes(file), charset); // let string_contents = read_to_string(&file)?; //new String(Files.readAllBytes(file), charset);
if string_contents.ends_with('\n') { if string_contents.ends_with('\n') {