Skip to content

Commit d7c8c81

Browse files
committed
Fix clippy lints
1 parent d02ec8a commit d7c8c81

File tree

7 files changed

+10
-7
lines changed

7 files changed

+10
-7
lines changed

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cognitive-complexity-threshold = 10
22
allow-expect-in-tests = true
33
allow-unwrap-in-tests = true
4+
doc-valid-idents = ["PnL", "PnLs", ".."]

crates/analysis/src/analyzer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl PortfolioAnalyzer {
198198
/// # Errors
199199
///
200200
/// Returns an error if:
201-
///
202201
/// - No currency is specified in a multi-currency portfolio.
203202
/// - The specified currency is not found in account balances.
204203
/// - The unrealized PnL currency does not match the specified currency.
@@ -241,7 +240,6 @@ impl PortfolioAnalyzer {
241240
/// # Errors
242241
///
243242
/// Returns an error if:
244-
///
245243
/// - No currency is specified in a multi-currency portfolio.
246244
/// - The specified currency is not found in account balances.
247245
/// - The unrealized PnL currency does not match the specified currency.

crates/backtest/src/engine.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ impl BacktestEngine {
196196
/// # Errors
197197
///
198198
/// Returns an error if:
199-
///
200199
/// - The instrument's associated venue has not been added via `add_venue`.
201200
/// - Attempting to add a `CurrencyPair` instrument for a single-currency CASH account.
202201
///

crates/backtest/src/exchange.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ impl SimulatedExchange {
137137
/// # Errors
138138
///
139139
/// Returns an error if:
140-
///
141140
/// - `starting_balances` is empty.
142141
/// - `base_currency` is `Some` but `starting_balances` contains multiple currencies.
143142
#[allow(clippy::too_many_arguments)]

crates/core/src/datetime.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub const WEEKDAYS: [Weekday; 5] = [
4646
/// Casting f64 to u64 by truncating the fractional part is intentional for unit conversion,
4747
/// which may lose precision and drop negative values after clamping.
4848
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
49+
#[must_use]
4950
pub fn secs_to_nanos(secs: f64) -> u64 {
5051
let nanos = secs * NANOSECONDS_IN_SECOND as f64;
5152
nanos.max(0.0).trunc() as u64
@@ -56,6 +57,7 @@ pub fn secs_to_nanos(secs: f64) -> u64 {
5657
/// Casting f64 to u64 by truncating the fractional part is intentional for unit conversion,
5758
/// which may lose precision and drop negative values after clamping.
5859
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
60+
#[must_use]
5961
pub fn secs_to_millis(secs: f64) -> u64 {
6062
let millis = secs * MILLISECONDS_IN_SECOND as f64;
6163
millis.max(0.0).trunc() as u64
@@ -66,6 +68,7 @@ pub fn secs_to_millis(secs: f64) -> u64 {
6668
/// Casting f64 to u64 by truncating the fractional part is intentional for unit conversion,
6769
/// which may lose precision and drop negative values after clamping.
6870
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
71+
#[must_use]
6972
pub fn millis_to_nanos(millis: f64) -> u64 {
7073
let nanos = millis * NANOSECONDS_IN_MILLISECOND as f64;
7174
nanos.max(0.0).trunc() as u64
@@ -76,6 +79,7 @@ pub fn millis_to_nanos(millis: f64) -> u64 {
7679
/// Casting f64 to u64 by truncating the fractional part is intentional for unit conversion,
7780
/// which may lose precision and drop negative values after clamping.
7881
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
82+
#[must_use]
7983
pub fn micros_to_nanos(micros: f64) -> u64 {
8084
let nanos = micros * NANOSECONDS_IN_MICROSECOND as f64;
8185
nanos.max(0.0).trunc() as u64
@@ -86,18 +90,21 @@ pub fn micros_to_nanos(micros: f64) -> u64 {
8690
/// Casting u64 to f64 may lose precision for large values,
8791
/// but is acceptable when computing fractional seconds.
8892
#[allow(clippy::cast_precision_loss)]
93+
#[must_use]
8994
pub fn nanos_to_secs(nanos: u64) -> f64 {
9095
let seconds = nanos / NANOSECONDS_IN_SECOND;
9196
let rem_nanos = nanos % NANOSECONDS_IN_SECOND;
9297
(seconds as f64) + (rem_nanos as f64) / (NANOSECONDS_IN_SECOND as f64)
9398
}
9499

95100
/// Converts nanoseconds (ns) to milliseconds (ms).
101+
#[must_use]
96102
pub const fn nanos_to_millis(nanos: u64) -> u64 {
97103
nanos / NANOSECONDS_IN_MILLISECOND
98104
}
99105

100106
/// Converts nanoseconds (ns) to microseconds (μs).
107+
#[must_use]
101108
pub const fn nanos_to_micros(nanos: u64) -> u64 {
102109
nanos / NANOSECONDS_IN_MICROSECOND
103110
}

crates/core/src/ffi/datetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ pub extern "C" fn nanos_to_secs(nanos: u64) -> f64 {
7272
/// Converts nanoseconds (ns) to milliseconds (ms).
7373
#[cfg(feature = "ffi")]
7474
#[unsafe(no_mangle)]
75-
pub extern "C" fn nanos_to_millis(nanos: u64) -> u64 {
75+
pub const extern "C" fn nanos_to_millis(nanos: u64) -> u64 {
7676
crate::datetime::nanos_to_millis(nanos)
7777
}
7878

7979
/// Converts nanoseconds (ns) to microseconds (μs).
8080
#[cfg(feature = "ffi")]
8181
#[unsafe(no_mangle)]
82-
pub extern "C" fn nanos_to_micros(nanos: u64) -> u64 {
82+
pub const extern "C" fn nanos_to_micros(nanos: u64) -> u64 {
8383
crate::datetime::nanos_to_micros(nanos)
8484
}

crates/infrastructure/src/redis/msgbus.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ impl MessageBusDatabaseAdapter for RedisMessageBusDatabase {
9191
/// Returns an error if:
9292
/// - The database configuration is missing in `config`.
9393
/// - Establishing the Redis connection for publishing fails.
94-
///
9594
fn new(
9695
trader_id: TraderId,
9796
instance_id: UUID4,

0 commit comments

Comments
 (0)