FIX: Make clippy happy
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
46ea92966f
commit
0be7d9b85a
@@ -46,18 +46,18 @@ impl fmt::Display for Complex {
|
||||
// it is a bit weird what Excel does but it seems it uses general notation for
|
||||
// numbers > 1e-20 and scientific notation for the rest
|
||||
let y_str = if y.abs() <= 9e-20 {
|
||||
format!("{:E}", y)
|
||||
format!("{y:E}")
|
||||
} else if y == 1.0 {
|
||||
"".to_string()
|
||||
} else if y == -1.0 {
|
||||
"-".to_string()
|
||||
} else {
|
||||
format!("{}", y)
|
||||
format!("{y}")
|
||||
};
|
||||
let x_str = if x.abs() <= 9e-20 {
|
||||
format!("{:E}", x)
|
||||
format!("{x:E}")
|
||||
} else {
|
||||
format!("{}", x)
|
||||
format!("{x}")
|
||||
};
|
||||
if y == 0.0 && x == 0.0 {
|
||||
write!(f, "0")
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
CalcResult::String(format!("{:0width$X}", HEX_MAX + value, width = 9))
|
||||
} else {
|
||||
let result = format!("{:X}", value);
|
||||
let result = format!("{value:X}");
|
||||
if let Some(places) = places {
|
||||
if places < result.len() as i32 {
|
||||
return CalcResult::new_error(
|
||||
@@ -120,7 +120,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
CalcResult::String(format!("{:0width$o}", OCT_MAX + value, width = 9))
|
||||
} else {
|
||||
let result = format!("{:o}", value);
|
||||
let result = format!("{value:o}");
|
||||
if let Some(places) = places {
|
||||
if places < result.len() as i32 {
|
||||
return CalcResult::new_error(
|
||||
@@ -163,7 +163,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += 1024;
|
||||
}
|
||||
let result = format!("{:b}", value);
|
||||
let result = format!("{value:b}");
|
||||
if let Some(places) = places {
|
||||
if value_raw > 0.0 && places < result.len() as i32 {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -202,7 +202,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += HEX_MAX;
|
||||
}
|
||||
let result = format!("{:X}", value);
|
||||
let result = format!("{value:X}");
|
||||
if let Some(places) = places {
|
||||
if value_raw > 0.0 && places < result.len() as i32 {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -242,7 +242,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += OCT_MAX;
|
||||
}
|
||||
let result = format!("{:o}", value);
|
||||
let result = format!("{value:o}");
|
||||
if let Some(places) = places {
|
||||
if value_raw > 0.0 && places < result.len() as i32 {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -301,7 +301,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += 1024;
|
||||
}
|
||||
let result = format!("{:b}", value);
|
||||
let result = format!("{value:b}");
|
||||
if let Some(places) = places {
|
||||
if places <= 0 || (value > 0 && places < result.len() as i32) {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -391,7 +391,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += OCT_MAX;
|
||||
}
|
||||
let result = format!("{:o}", value);
|
||||
let result = format!("{value:o}");
|
||||
if let Some(places) = places {
|
||||
if places <= 0 || (value > 0 && places < result.len() as i32) {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -446,7 +446,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += 1024;
|
||||
}
|
||||
let result = format!("{:b}", value);
|
||||
let result = format!("{value:b}");
|
||||
if let Some(places) = places {
|
||||
if value < 512 && places < result.len() as i32 {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
@@ -532,7 +532,7 @@ impl Model {
|
||||
if value < 0 {
|
||||
value += HEX_MAX;
|
||||
}
|
||||
let result = format!("{:X}", value);
|
||||
let result = format!("{value:X}");
|
||||
if let Some(places) = places {
|
||||
if value < HEX_MAX_HALF && places < result.len() as i32 {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Out of bounds".to_string());
|
||||
|
||||
@@ -231,7 +231,7 @@ impl Model {
|
||||
CalcResult::new_error(
|
||||
Error::ERROR,
|
||||
*cell,
|
||||
format!("Invalid worksheet index: '{}'", sheet),
|
||||
format!("Invalid worksheet index: '{sheet}'"),
|
||||
)
|
||||
})?
|
||||
.dimension()
|
||||
@@ -245,7 +245,7 @@ impl Model {
|
||||
CalcResult::new_error(
|
||||
Error::ERROR,
|
||||
*cell,
|
||||
format!("Invalid worksheet index: '{}'", sheet),
|
||||
format!("Invalid worksheet index: '{sheet}'"),
|
||||
)
|
||||
})?
|
||||
.dimension()
|
||||
|
||||
@@ -1214,7 +1214,7 @@ mod tests {
|
||||
}
|
||||
// We make a list with their functions names, but we escape ".": ERROR.TYPE => ERRORTYPE
|
||||
let iter_list = Function::into_iter()
|
||||
.map(|f| format!("{}", f).replace('.', ""))
|
||||
.map(|f| format!("{f}").replace('.', ""))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let len = iter_list.len();
|
||||
|
||||
@@ -55,14 +55,14 @@ impl Model {
|
||||
let mut result = "".to_string();
|
||||
for arg in args {
|
||||
match self.evaluate_node_in_context(arg, cell) {
|
||||
CalcResult::String(value) => result = format!("{}{}", result, value),
|
||||
CalcResult::Number(value) => result = format!("{}{}", result, value),
|
||||
CalcResult::String(value) => result = format!("{result}{value}"),
|
||||
CalcResult::Number(value) => result = format!("{result}{value}"),
|
||||
CalcResult::EmptyCell | CalcResult::EmptyArg => {}
|
||||
CalcResult::Boolean(value) => {
|
||||
if value {
|
||||
result = format!("{}TRUE", result);
|
||||
result = format!("{result}TRUE");
|
||||
} else {
|
||||
result = format!("{}FALSE", result);
|
||||
result = format!("{result}FALSE");
|
||||
}
|
||||
}
|
||||
error @ CalcResult::Error { .. } => return error,
|
||||
@@ -82,16 +82,16 @@ impl Model {
|
||||
column,
|
||||
}) {
|
||||
CalcResult::String(value) => {
|
||||
result = format!("{}{}", result, value);
|
||||
result = format!("{result}{value}");
|
||||
}
|
||||
CalcResult::Number(value) => {
|
||||
result = format!("{}{}", result, value)
|
||||
result = format!("{result}{value}")
|
||||
}
|
||||
CalcResult::Boolean(value) => {
|
||||
if value {
|
||||
result = format!("{}TRUE", result);
|
||||
result = format!("{result}TRUE");
|
||||
} else {
|
||||
result = format!("{}FALSE", result);
|
||||
result = format!("{result}FALSE");
|
||||
}
|
||||
}
|
||||
error @ CalcResult::Error { .. } => return error,
|
||||
@@ -282,7 +282,7 @@ impl Model {
|
||||
pub(crate) fn fn_len(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 1 {
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -317,7 +317,7 @@ impl Model {
|
||||
pub(crate) fn fn_trim(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 1 {
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -352,7 +352,7 @@ impl Model {
|
||||
pub(crate) fn fn_lower(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 1 {
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -387,7 +387,7 @@ impl Model {
|
||||
pub(crate) fn fn_unicode(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 1 {
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -441,7 +441,7 @@ impl Model {
|
||||
pub(crate) fn fn_upper(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 1 {
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -478,7 +478,7 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -560,7 +560,7 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
@@ -642,7 +642,7 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let s = match self.evaluate_node_in_context(&args[0], cell) {
|
||||
CalcResult::Number(v) => format!("{}", v),
|
||||
CalcResult::Number(v) => format!("{v}"),
|
||||
CalcResult::String(v) => v,
|
||||
CalcResult::Boolean(b) => {
|
||||
if b {
|
||||
|
||||
@@ -110,7 +110,7 @@ pub(crate) fn from_wildcard_to_regex(
|
||||
|
||||
// And we have a valid Perl regex! (As Kim Kardashian said before me: "I know, right?")
|
||||
if exact {
|
||||
return regex::Regex::new(&format!("^{}$", reg));
|
||||
return regex::Regex::new(&format!("^{reg}$"));
|
||||
}
|
||||
regex::Regex::new(reg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user