FIX: Make clippy happy

This is mostly Rust 1.83
This commit is contained in:
Nicolás Hatcher
2024-11-29 19:39:20 +01:00
committed by Nicolás Hatcher Andrés
parent 1f5f575e7a
commit e065477b5a
6 changed files with 33 additions and 33 deletions

View File

@@ -12,7 +12,7 @@ const EPS_LOW: f64 = 1e-6;
// Known values computed with Arb via Nemo.jl in Julia // Known values computed with Arb via Nemo.jl in Julia
// You can also use Mathematica // You can also use Mathematica
/// But please do not use Excel or any other software without arbitrary precision // But please do not use Excel or any other software without arbitrary precision
fn numbers_are_close(a: f64, b: f64) -> bool { fn numbers_are_close(a: f64, b: f64) -> bool {
if a == b { if a == b {

View File

@@ -1337,21 +1337,21 @@ impl Model {
CalcResult::Number(result) CalcResult::Number(result)
} }
/// This next three functions deal with Treasure Bills or T-Bills for short // This next three functions deal with Treasure Bills or T-Bills for short
/// They are zero-coupon that mature in one year or less. // They are zero-coupon that mature in one year or less.
/// Definitions: // Definitions:
/// $r$ be the discount rate // $r$ be the discount rate
/// $v$ the face value of the Bill // $v$ the face value of the Bill
/// $p$ the price of the Bill // $p$ the price of the Bill
/// $d_m$ is the number of days from the settlement to maturity // $d_m$ is the number of days from the settlement to maturity
/// Then: // Then:
/// $$ p = v \times\left(1-\frac{d_m}{r}\right) $$ // $$ p = v \times\left(1-\frac{d_m}{r}\right) $$
/// If d_m is less than 183 days the he Bond Equivalent Yield (BEY, here $y$) is given by: // If d_m is less than 183 days the he Bond Equivalent Yield (BEY, here $y$) is given by:
/// $$ y = \frac{F - B}{M}\times \frac{365}{d_m} = \frac{365\times r}{360-r\times d_m} // $$ y = \frac{F - B}{M}\times \frac{365}{d_m} = \frac{365\times r}{360-r\times d_m}
/// If d_m>= 183 days things are a bit more complicated. // If d_m>= 183 days things are a bit more complicated.
/// Let $d_e = d_m - 365/2$ if $d_m <= 365$ or $d_e = 183$ if $d_m = 366$. // Let $d_e = d_m - 365/2$ if $d_m <= 365$ or $d_e = 183$ if $d_m = 366$.
/// $$ v = p\times \left(1+\frac{y}{2}\right)\left(1+d_e\times\frac{y}{365}\right) $$ // $$ v = p\times \left(1+\frac{y}{2}\right)\left(1+d_e\times\frac{y}{365}\right) $$
/// Together with the previous relation of $p$ and $v$ gives us a quadratic equation for $y$. // Together with the previous relation of $p$ and $v$ gives us a quadratic equation for $y$.
// TBILLEQ(settlement, maturity, discount) // TBILLEQ(settlement, maturity, discount)
pub(crate) fn fn_tbilleq(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult { pub(crate) fn fn_tbilleq(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {

View File

@@ -550,7 +550,7 @@ impl Model {
} }
result.push(ch); result.push(ch);
} }
return CalcResult::String(result.chars().rev().collect::<String>()); CalcResult::String(result.chars().rev().collect::<String>())
} }
pub(crate) fn fn_mid(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult { pub(crate) fn fn_mid(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {

View File

@@ -26,9 +26,9 @@ pub(crate) fn values_are_equal(left: &CalcResult, right: &CalcResult) -> bool {
} }
} }
/// In Excel there are two ways of comparing cell values. // In Excel there are two ways of comparing cell values.
/// The old school comparison valid in formulas like D3 < D4 or HLOOKUP,... cast empty cells into empty strings or 0 // The old school comparison valid in formulas like D3 < D4 or HLOOKUP,... cast empty cells into empty strings or 0
/// For the new formulas like XLOOKUP or SORT an empty cell is always larger than anything else. // For the new formulas like XLOOKUP or SORT an empty cell is always larger than anything else.
// ..., -2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; // ..., -2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE;
pub(crate) fn compare_values(left: &CalcResult, right: &CalcResult) -> i32 { pub(crate) fn compare_values(left: &CalcResult, right: &CalcResult) -> i32 {
@@ -115,8 +115,8 @@ pub(crate) fn from_wildcard_to_regex(
regex::Regex::new(reg) regex::Regex::new(reg)
} }
/// NUMBERS /// // NUMBERS ///
///*********/// //*********///
// It could be either the number or a string representation of the number // It could be either the number or a string representation of the number
// In the rest of the cases calc_result needs to be a number (cannot be the string "23", for instance) // In the rest of the cases calc_result needs to be a number (cannot be the string "23", for instance)
@@ -181,8 +181,8 @@ fn result_is_not_equal_to_number(calc_result: &CalcResult, target: f64) -> bool
} }
} }
/// BOOLEANS /// // BOOLEANS ///
///**********/// //**********///
// Booleans have to be "exactly" equal // Booleans have to be "exactly" equal
fn result_is_equal_to_bool(calc_result: &CalcResult, target: bool) -> bool { fn result_is_equal_to_bool(calc_result: &CalcResult, target: bool) -> bool {
@@ -199,10 +199,10 @@ fn result_is_not_equal_to_bool(calc_result: &CalcResult, target: bool) -> bool {
} }
} }
/// STRINGS /// // STRINGS ///
///*********/// //*********///
/// Note that strings are case insensitive. `target` must always be lower case. // Note that strings are case insensitive. `target` must always be lower case.
pub(crate) fn result_matches_regex(calc_result: &CalcResult, reg: &regex::Regex) -> bool { pub(crate) fn result_matches_regex(calc_result: &CalcResult, reg: &regex::Regex) -> bool {
match calc_result { match calc_result {
@@ -270,8 +270,8 @@ fn result_is_greater_or_equal_than_string(calc_result: &CalcResult, target: &str
} }
} }
/// ERRORS /// // ERRORS ///
///********/// //********///
fn result_is_equal_to_error(calc_result: &CalcResult, target: &str) -> bool { fn result_is_equal_to_error(calc_result: &CalcResult, target: &str) -> bool {
match calc_result { match calc_result {
@@ -287,8 +287,8 @@ fn result_is_not_equal_to_error(calc_result: &CalcResult, target: &str) -> bool
} }
} }
/// EMPTY /// // EMPTY ///
///*******/// //*******///
// Note that these two are not inverse of each other. // Note that these two are not inverse of each other.
// In particular, you can never match an empty cell. // In particular, you can never match an empty cell.

View File

@@ -214,7 +214,7 @@ impl PyModel {
} }
} }
/// Create methods // Create methods
/// Loads a function from an xlsx file /// Loads a function from an xlsx file
#[pyfunction] #[pyfunction]

View File

@@ -56,7 +56,7 @@ impl<'a> Process<'a> {
} }
} }
impl<'a> Extend<(usize, Value)> for Process<'a> { impl Extend<(usize, Value)> for Process<'_> {
fn extend<I: IntoIterator<Item = (usize, Value)>>(&mut self, it: I) { fn extend<I: IntoIterator<Item = (usize, Value)>>(&mut self, it: I) {
for v in it.into_iter() { for v in it.into_iter() {
self.process(v); self.process(v);