FIX: Make clippy happy
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
46ea92966f
commit
0be7d9b85a
@@ -142,7 +142,7 @@ impl Lexer {
|
||||
pub fn expect(&mut self, tk: TokenType) -> Result<()> {
|
||||
let nt = self.next_token();
|
||||
if mem::discriminant(&nt) != mem::discriminant(&tk) {
|
||||
return Err(self.set_error(&format!("Error, expected {:?}", tk), self.position));
|
||||
return Err(self.set_error(&format!("Error, expected {tk:?}"), self.position));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -511,7 +511,7 @@ impl Lexer {
|
||||
self.position = position;
|
||||
chars.parse::<i32>().map_err(|_| LexerError {
|
||||
position,
|
||||
message: format!("Failed to parse to int: {}", chars),
|
||||
message: format!("Failed to parse to int: {chars}"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -573,7 +573,7 @@ impl Lexer {
|
||||
self.position = position;
|
||||
match chars.parse::<f64>() {
|
||||
Err(_) => {
|
||||
Err(self.set_error(&format!("Failed to parse to double: {}", chars), position))
|
||||
Err(self.set_error(&format!("Failed to parse to double: {chars}"), position))
|
||||
}
|
||||
Ok(v) => Ok(v),
|
||||
}
|
||||
|
||||
@@ -149,14 +149,14 @@ impl Lexer {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_left), position))
|
||||
.set_error(&format!("Failed parsing row {row_left}"), position))
|
||||
}
|
||||
};
|
||||
let row_right = match row_right.parse::<i32>() {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_right), position))
|
||||
.set_error(&format!("Failed parsing row {row_right}"), position))
|
||||
}
|
||||
};
|
||||
if row_left > LAST_ROW {
|
||||
|
||||
@@ -828,7 +828,7 @@ impl Parser {
|
||||
| TokenType::Percent => Node::ParseErrorKind {
|
||||
formula: self.lexer.get_formula(),
|
||||
position: 0,
|
||||
message: format!("Unexpected token: '{:?}'", next_token),
|
||||
message: format!("Unexpected token: '{next_token:?}'"),
|
||||
},
|
||||
TokenType::LeftBracket => Node::ParseErrorKind {
|
||||
formula: self.lexer.get_formula(),
|
||||
|
||||
@@ -53,24 +53,24 @@ fn move_function(name: &str, args: &Vec<Node>, move_context: &MoveContext) -> St
|
||||
arguments = to_string_moved(el, move_context);
|
||||
}
|
||||
}
|
||||
format!("{}({})", name, arguments)
|
||||
format!("{name}({arguments})")
|
||||
}
|
||||
|
||||
pub(crate) fn to_string_array_node(node: &ArrayNode) -> String {
|
||||
match node {
|
||||
ArrayNode::Boolean(value) => format!("{}", value).to_ascii_uppercase(),
|
||||
ArrayNode::Boolean(value) => format!("{value}").to_ascii_uppercase(),
|
||||
ArrayNode::Number(number) => to_excel_precision_str(*number),
|
||||
ArrayNode::String(value) => format!("\"{}\"", value),
|
||||
ArrayNode::Error(kind) => format!("{}", kind),
|
||||
ArrayNode::String(value) => format!("\"{value}\""),
|
||||
ArrayNode::Error(kind) => format!("{kind}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
use self::Node::*;
|
||||
match node {
|
||||
BooleanKind(value) => format!("{}", value).to_ascii_uppercase(),
|
||||
BooleanKind(value) => format!("{value}").to_ascii_uppercase(),
|
||||
NumberKind(number) => to_excel_precision_str(*number),
|
||||
StringKind(value) => format!("\"{}\"", value),
|
||||
StringKind(value) => format!("\"{value}\""),
|
||||
ReferenceKind {
|
||||
sheet_name,
|
||||
sheet_index,
|
||||
@@ -241,7 +241,7 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
full_row,
|
||||
full_column,
|
||||
);
|
||||
format!("{}:{}", s1, s2)
|
||||
format!("{s1}:{s2}")
|
||||
}
|
||||
WrongReferenceKind {
|
||||
sheet_name,
|
||||
@@ -325,7 +325,7 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
full_row,
|
||||
full_column,
|
||||
);
|
||||
format!("{}:{}", s1, s2)
|
||||
format!("{s1}:{s2}")
|
||||
}
|
||||
OpRangeKind { left, right } => format!(
|
||||
"{}:{}",
|
||||
@@ -358,7 +358,7 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
}
|
||||
_ => to_string_moved(right, move_context),
|
||||
};
|
||||
format!("{}{}{}", x, kind, y)
|
||||
format!("{x}{kind}{y}")
|
||||
}
|
||||
OpPowerKind { left, right } => format!(
|
||||
"{}^{}",
|
||||
@@ -403,7 +403,7 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
}
|
||||
|
||||
// Enclose the whole matrix in braces
|
||||
format!("{{{}}}", matrix_string)
|
||||
format!("{{{matrix_string}}}")
|
||||
}
|
||||
DefinedNameKind((name, ..)) => name.to_string(),
|
||||
TableNameKind(name) => name.to_string(),
|
||||
@@ -418,7 +418,7 @@ fn to_string_moved(node: &Node, move_context: &MoveContext) -> String {
|
||||
OpUnary::Minus => format!("-{}", to_string_moved(right, move_context)),
|
||||
OpUnary::Percentage => format!("{}%", to_string_moved(right, move_context)),
|
||||
},
|
||||
ErrorKind(kind) => format!("{}", kind),
|
||||
ErrorKind(kind) => format!("{kind}"),
|
||||
ParseErrorKind {
|
||||
formula,
|
||||
message: _,
|
||||
|
||||
@@ -184,16 +184,16 @@ pub(crate) fn stringify_reference(
|
||||
return "#REF!".to_string();
|
||||
}
|
||||
let mut row_abs = if absolute_row {
|
||||
format!("${}", row)
|
||||
format!("${row}")
|
||||
} else {
|
||||
format!("{}", row)
|
||||
format!("{row}")
|
||||
};
|
||||
let column = match crate::expressions::utils::number_to_column(column) {
|
||||
Some(s) => s,
|
||||
None => return "#REF!".to_string(),
|
||||
};
|
||||
let mut col_abs = if absolute_column {
|
||||
format!("${}", column)
|
||||
format!("${column}")
|
||||
} else {
|
||||
column
|
||||
};
|
||||
@@ -208,27 +208,27 @@ pub(crate) fn stringify_reference(
|
||||
format!("{}!{}{}", quote_name(name), col_abs, row_abs)
|
||||
}
|
||||
None => {
|
||||
format!("{}{}", col_abs, row_abs)
|
||||
format!("{col_abs}{row_abs}")
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let row_abs = if absolute_row {
|
||||
format!("R{}", row)
|
||||
format!("R{row}")
|
||||
} else {
|
||||
format!("R[{}]", row)
|
||||
format!("R[{row}]")
|
||||
};
|
||||
let col_abs = if absolute_column {
|
||||
format!("C{}", column)
|
||||
format!("C{column}")
|
||||
} else {
|
||||
format!("C[{}]", column)
|
||||
format!("C[{column}]")
|
||||
};
|
||||
match &sheet_name {
|
||||
Some(name) => {
|
||||
format!("{}!{}{}", quote_name(name), row_abs, col_abs)
|
||||
}
|
||||
None => {
|
||||
format!("{}{}", row_abs, col_abs)
|
||||
format!("{row_abs}{col_abs}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ fn format_function(
|
||||
arguments = stringify(el, context, displace_data, export_to_excel);
|
||||
}
|
||||
}
|
||||
format!("{}({})", name, arguments)
|
||||
format!("{name}({arguments})")
|
||||
}
|
||||
|
||||
// There is just one representation in the AST (Abstract Syntax Tree) of a formula.
|
||||
@@ -292,9 +292,9 @@ fn stringify(
|
||||
) -> String {
|
||||
use self::Node::*;
|
||||
match node {
|
||||
BooleanKind(value) => format!("{}", value).to_ascii_uppercase(),
|
||||
BooleanKind(value) => format!("{value}").to_ascii_uppercase(),
|
||||
NumberKind(number) => to_excel_precision_str(*number),
|
||||
StringKind(value) => format!("\"{}\"", value),
|
||||
StringKind(value) => format!("\"{value}\""),
|
||||
WrongReferenceKind {
|
||||
sheet_name,
|
||||
column,
|
||||
@@ -384,7 +384,7 @@ fn stringify(
|
||||
full_row,
|
||||
full_column,
|
||||
);
|
||||
format!("{}:{}", s1, s2)
|
||||
format!("{s1}:{s2}")
|
||||
}
|
||||
WrongRangeKind {
|
||||
sheet_name,
|
||||
@@ -433,7 +433,7 @@ fn stringify(
|
||||
full_row,
|
||||
full_column,
|
||||
);
|
||||
format!("{}:{}", s1, s2)
|
||||
format!("{s1}:{s2}")
|
||||
}
|
||||
OpRangeKind { left, right } => format!(
|
||||
"{}:{}",
|
||||
@@ -484,7 +484,7 @@ fn stringify(
|
||||
),
|
||||
_ => stringify(right, context, displace_data, export_to_excel),
|
||||
};
|
||||
format!("{}{}{}", x, kind, y)
|
||||
format!("{x}{kind}{y}")
|
||||
}
|
||||
OpPowerKind { left, right } => {
|
||||
let x = match **left {
|
||||
@@ -547,7 +547,7 @@ fn stringify(
|
||||
stringify(right, context, displace_data, export_to_excel)
|
||||
),
|
||||
};
|
||||
format!("{}^{}", x, y)
|
||||
format!("{x}^{y}")
|
||||
}
|
||||
InvalidFunctionKind { name, args } => {
|
||||
format_function(name, args, context, displace_data, export_to_excel)
|
||||
@@ -582,7 +582,7 @@ fn stringify(
|
||||
}
|
||||
matrix_string.push_str(&row_string);
|
||||
}
|
||||
format!("{{{}}}", matrix_string)
|
||||
format!("{{{matrix_string}}}")
|
||||
}
|
||||
TableNameKind(value) => value.to_string(),
|
||||
DefinedNameKind((name, ..)) => name.to_string(),
|
||||
@@ -601,7 +601,7 @@ fn stringify(
|
||||
)
|
||||
}
|
||||
},
|
||||
ErrorKind(kind) => format!("{}", kind),
|
||||
ErrorKind(kind) => format!("{kind}"),
|
||||
ParseErrorKind {
|
||||
formula,
|
||||
position: _,
|
||||
|
||||
Reference in New Issue
Block a user