Skip to content

Commit

Permalink
Merge pull request #139 from lumeohq/dmitry/fix-clippy-warnings
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
DmitrySamoylov authored Aug 11, 2022
2 parents 7f3d433 + beb2ccd commit d8dd37e
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions wsdl-parser/src/parser/port_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ impl<'a> OperationType<'a> {
assert_eq!(
output_node.wsdl_type(),
ElementType::Output,
"{}",
format!("{:?}", output_node)
"{:?}",
output_node
);
OperationType::RequestResponse {
input: Param::new(&ch),
Expand Down
2 changes: 1 addition & 1 deletion xsd-parser/src/parser/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::cell::RefCell;
pub fn parse_union(union: &Node) -> RsEntity {
let mut cases = union
.attribute(attribute::MEMBER_TYPES)
.map(|s| create_enum_cases(s))
.map(create_enum_cases)
.unwrap_or_else(Vec::new);

let subtypes = union
Expand Down
2 changes: 1 addition & 1 deletion xsd-types/src/types/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl FromStr for Decimal {

impl fmt::Display for Decimal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0.to_string())
write!(f, "{}", self.0)
}
}

Expand Down
15 changes: 8 additions & 7 deletions xsd-types/src/types/duration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt;
use std::fmt::Write;
use std::str::FromStr;
use xsd_macro_utils::UtilsDefaultSerde;

Expand Down Expand Up @@ -166,7 +167,7 @@ impl FromStr for Duration {
context.is_dot_found = true;
}
digit => {
if !digit.is_digit(10) {
if !digit.is_ascii_digit() {
return Err("Incorrect character occurred".into());
}

Expand Down Expand Up @@ -215,24 +216,24 @@ impl fmt::Display for Duration {

let mut date_str = String::new();
if self.years > 0 {
date_str.push_str(&format!("{}Y", self.years));
write!(&mut date_str, "{}Y", self.years)?;
}
if self.months > 0 {
date_str.push_str(&format!("{}M", self.months));
write!(&mut date_str, "{}M", self.months)?;
}
if self.days > 0 {
date_str.push_str(&format!("{}D", self.days));
write!(&mut date_str, "{}D", self.days)?;
}

let mut time_str = String::new();
if self.hours > 0 {
time_str.push_str(&format!("{}H", self.hours));
write!(&mut time_str, "{}H", self.hours)?;
}
if self.minutes > 0 {
time_str.push_str(&format!("{}M", self.minutes));
write!(&mut time_str, "{}M", self.minutes)?;
}
if self.seconds > 0.0 {
time_str.push_str(&format!("{}S", self.seconds));
write!(&mut time_str, "{}S", self.seconds)?;
}

if time_str.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion xsd-types/src/types/gday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl FromStr for GDay {
return Err("bad gDay format".to_string());
}
let token = &s[3..5];
if !token.chars().all(|c| c.is_digit(10)) {
if !token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad gDay format".to_string());
}
token.parse::<i32>().map_err(|e| e.to_string())
Expand Down
2 changes: 1 addition & 1 deletion xsd-types/src/types/gmonth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl FromStr for GMonth {
return Err("bad gMonth format".to_string());
}
let token = &s[2..4];
if !token.chars().all(|c| c.is_digit(10)) {
if !token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad gMonth format".to_string());
}
token.parse::<i32>().map_err(|e| e.to_string())
Expand Down
4 changes: 2 additions & 2 deletions xsd-types/src/types/gmonthday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ impl FromStr for GMonthDay {
}

let month_token = &s[2..4];
if !month_token.chars().all(|c| c.is_digit(10)) {
if !month_token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad month format within gMonthDay".to_string());
}
let month = month_token.parse::<i32>().map_err(|e| e.to_string())?;

let day_token = &s[5..7];
if !day_token.chars().all(|c| c.is_digit(10)) {
if !day_token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad day format within gMonthDay".to_string());
}
let day = day_token.parse::<i32>().map_err(|e| e.to_string())?;
Expand Down
2 changes: 1 addition & 1 deletion xsd-types/src/types/gyear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn parse_str_positive(s: &str) -> Result<GYear, String> {
if s.len() < 4 {
return Err("bad gYear format: to short".to_string());
}
if !s.chars().all(|c| c.is_digit(10)) {
if !s.chars().all(|c| c.is_ascii_digit()) {
return Err("bad gYear format".to_string());
}
s.parse::<i32>().map_err(|e| e.to_string())
Expand Down
4 changes: 2 additions & 2 deletions xsd-types/src/types/gyearmonth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ fn parse_str_positive(s: &str) -> Result<GYearMonth, String> {
return Err("bad gYearMonth format".to_string());
}

if !year_token.chars().all(|c| c.is_digit(10)) {
if !year_token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad year format within gYearMonth".to_string());
}
let year = year_token.parse::<i32>().map_err(|e| e.to_string())?;

if !month_token.chars().all(|c| c.is_digit(10)) {
if !month_token.chars().all(|c| c.is_ascii_digit()) {
return Err("bad month format within gYearMonth".to_string());
}
let month = month_token.parse::<i32>().map_err(|e| e.to_string())?;
Expand Down
2 changes: 1 addition & 1 deletion xsd-types/src/types/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn parse_timezone(s: &str) -> Result<FixedOffset, String> {
if tokens.len() != 2 || tokens[0].len() != 2 || tokens[1].len() != 2 {
return Err("bad timezone format".to_string());
}
if !tokens.iter().all(|t| t.chars().all(|c| c.is_digit(10))) {
if !tokens.iter().all(|t| t.chars().all(|c| c.is_ascii_digit())) {
return Err("bad timezone format".to_string());
}

Expand Down

0 comments on commit d8dd37e

Please sign in to comment.