diff --git a/Cargo.toml b/Cargo.toml index 3638048..3e15115 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,38 @@ aligned-vec = "0.6.4" bytemuck = { version = "1.24.0", features = ["derive"] } chrono = "0.4.42" saphyr = "0.0.6" + +[lints.clippy] +cloned_instead_of_copied = "warn" +copy_iterator = "warn" +dbg_macro = "warn" +default_trait_access = "warn" +elidable_lifetime_names = "warn" +explicit_into_iter_loop = "warn" +explicit_iter_loop = "warn" +ignore_without_reason = "warn" +ignored_unit_patterns = "warn" +implicit_clone = "warn" +inconsistent_struct_constructor = "warn" +inefficient_to_string = "warn" +into_iter_without_iter = "warn" +manual_let_else = "warn" +needless_continue = "warn" +needless_pass_by_value = "warn" +no_effect_underscore_binding = "warn" +redundant_closure_for_method_calls = "warn" +ref_option = "warn" +ref_option_ref = "warn" +semicolon_if_nothing_returned = "warn" +single_match_else = "warn" +trivially_copy_pass_by_ref = "warn" +uninlined_format_args = "warn" +unnecessary_debug_formatting = "warn" +unnecessary_literal_bound = "warn" +unnecessary_semicolon = "warn" +unnecessary_wraps = "warn" +unnested_or_patterns = "warn" +unused_self = "warn" +used_underscore_binding = "warn" +unwrap_used = "warn" + diff --git a/src/telemetry.rs b/src/telemetry.rs index d1595d9..9d7a385 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -59,10 +59,22 @@ pub struct VarHeader { impl Header { pub fn from_raw(raw: &raw::Header) -> Self { Self { - tick_rate: raw.tick_rate.try_into().unwrap(), - session_info_update: raw.session_info_update.try_into().unwrap(), - session_info_len: raw.session_info_len.try_into().unwrap(), - session_info_offset: raw.session_info_offset.try_into().unwrap(), + tick_rate: raw + .tick_rate + .try_into() + .expect("`tick_rate` should be positive"), + session_info_update: raw + .session_info_update + .try_into() + .expect("`session_info_update` should be positive"), + session_info_len: raw + .session_info_len + .try_into() + .expect("`session_info_len` should be positive"), + session_info_offset: raw + .session_info_offset + .try_into() + .expect("`session_info_offset` should be positive"), } } @@ -78,10 +90,14 @@ impl Header { impl DiskSubHeader { pub fn from_raw(raw: &raw::DiskSubHeader) -> Self { Self { - date: DateTime::from_timestamp_secs(raw.session_start_date).unwrap(), + date: DateTime::from_timestamp_secs(raw.session_start_date) + .expect("`session_start_date` should be a valid timestamp"), start_time: Duration::from_secs_f64(raw.session_start_time), end_time: Duration::from_secs_f64(raw.session_end_time), - lap_count: raw.session_lap_count.try_into().unwrap(), + lap_count: raw + .session_lap_count + .try_into() + .expect("`session_lap_count` should be positive"), } } } @@ -100,8 +116,8 @@ impl VarHeader { Self { ty, - offset: raw.offset.try_into().unwrap(), - count: raw.count.try_into().unwrap(), + offset: raw.offset.try_into().expect("`offset` to be positive"), + count: raw.count.try_into().expect("`count` to be positive"), count_as_time: raw.count_as_time == 0, name: string_from_c_chars(&raw.name), description: string_from_c_chars(&raw.desc),