diff --git a/src/replay.rs b/src/replay.rs index 586b462..e69df53 100644 --- a/src/replay.rs +++ b/src/replay.rs @@ -3,7 +3,6 @@ use std::io; use std::io::Read; use std::io::Result as IOResult; use std::io::{Error as IOError, ErrorKind}; -use std::u32; /// Magic number found at the start of replay files pub const FILE_MAGIC: &[u8] = b"YLPR"; @@ -170,7 +169,7 @@ fn read_str(mut reader: R, length: usize) -> IOResult { .position(|&b| b == 0) .expect("Given string does not terminate within given length"); - Ok(String::from_utf8((&raw_string_bytes[..nul]).to_vec()).unwrap()) + Ok(String::from_utf8((raw_string_bytes[..nul]).to_vec()).unwrap()) } impl Replay { diff --git a/src/telemetry.rs b/src/telemetry.rs index 7094ed1..83bd7d6 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -438,8 +438,7 @@ impl Sample { let raw_val = &self.buffer[vs..ve]; - let v: Value; - v = match vt { + let v: Value = match vt { Value::INT(_) => { if vc == 1 { Value::INT(i32::from_le_bytes(raw_val.try_into().unwrap())) @@ -475,7 +474,7 @@ impl Sample { } Value::DOUBLE(_) => Value::DOUBLE(f64::from_le_bytes(raw_val.try_into().unwrap())), Value::BITS(_) => Value::BITS(u32::from_le_bytes(raw_val.try_into().unwrap())), - Value::CHAR(_) => Value::CHAR(raw_val[0] as u8), + Value::CHAR(_) => Value::CHAR(raw_val[0]), Value::BOOL(_) => { if vc == 1 { Value::BOOL(raw_val[0] > 0) @@ -539,8 +538,8 @@ pub enum SampleError { NoValue(String), } -impl<'conn> Blocking<'conn> { - fn new(location: *const c_void) -> IOResult { +impl Blocking<'_> { + fn new(location: *const c_void) -> std::io::Result { let mut event_name: Vec = DATA_EVENT_NAME.encode_utf16().collect(); event_name.push(0); @@ -617,7 +616,7 @@ impl<'conn> Blocking<'conn> { } } -impl<'conn> Drop for Blocking<'conn> { +impl Drop for Blocking<'_> { fn drop(&mut self) { unsafe { let succ = CloseHandle(self.event_handle); @@ -800,7 +799,7 @@ mod tests { #[test] fn test_latest_telemetry() { - let session_tick: u32 = Connection::new() + let session_tick: Sample = Connection::new() .expect("Unable to open telemetry") .telemetry(); } diff --git a/src/track_surface.rs b/src/track_surface.rs index d86ddd9..e3bc163 100644 --- a/src/track_surface.rs +++ b/src/track_surface.rs @@ -25,15 +25,15 @@ impl From for TrackSurface { match idx { -1 => TrackSurface::NotInWorld, 0 => TrackSurface::Undefined, - 1 | 2 | 3 | 4 => TrackSurface::Asphalt(ix), + 1..=4 => TrackSurface::Asphalt(ix), 6 | 7 => TrackSurface::Concrete(ix - 4), 8 | 9 => TrackSurface::RacingDirt(ix - 7), 10 | 11 => TrackSurface::Paint(ix - 9), - 12 | 13 | 14 | 15 => TrackSurface::Rumble(ix - 11), - 16 | 17 | 18 | 19 => TrackSurface::Grass(ix - 15), - 20 | 21 | 22 | 23 => TrackSurface::Dirt(ix - 19), + 12..=15 => TrackSurface::Rumble(ix - 11), + 16..=19 => TrackSurface::Grass(ix - 15), + 20..=23 => TrackSurface::Dirt(ix - 19), 24 => TrackSurface::Sand, - 25 | 26 | 27 | 28 => TrackSurface::Gravel(ix - 24), + 25..=28 => TrackSurface::Gravel(ix - 24), 29 => TrackSurface::Grasscrete, 30 => TrackSurface::Astroturf, _ => TrackSurface::Unknown(ix),