From: Tim "tim3z" Zeitz Date: Thu, 16 Dec 2021 09:47:11 +0000 (+0100) Subject: updates, clippy, formatting X-Git-Url: https://i11git.iti.kit.edu/anon-gitweb/?p=Mitarbeiter%2FTim-Zeitz%2Fstud-rust-base.git;a=commitdiff_plain;h=3f62b84a17b4e656eba2156ebf30f6f2eeef5c55;ds=sidebyside updates, clippy, formatting --- diff --git a/Cargo.lock b/Cargo.lock index 2d33e1d..b98a97a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,53 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "libc" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +version = 3 [[package]] name = "stud-rust-base" version = "0.1.0" -dependencies = [ - "time", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi", - "winapi", -] - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 344beb8..42ddd25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,4 @@ name = "stud-rust-base" version = "0.1.0" authors = ["Tim Zeitz "] -edition = '2018' - -[dependencies] -time = "^0.1.40" +edition = '2021' diff --git a/src/bin/example.rs b/src/bin/example.rs index 667bff3..e1eb51f 100644 --- a/src/bin/example.rs +++ b/src/bin/example.rs @@ -3,7 +3,7 @@ use stud_rust_base::{io::*, time::report_time, types::*}; use std::{env, error::Error, path::Path}; fn main() -> Result<(), Box> { - let arg = &env::args().skip(1).next().expect("No directory arg given"); + let arg = &env::args().nth(1).expect("No directory arg given"); let path = Path::new(arg); let first_out = Vec::::load_from(path.join("first_out"))?; diff --git a/src/index_heap.rs b/src/index_heap.rs index 5850ae8..2c6f613 100644 --- a/src/index_heap.rs +++ b/src/index_heap.rs @@ -168,10 +168,7 @@ impl IndexdMinHeap { let mut hole = Hole::new(&mut self.data, position); loop { - if let Some(smallest_child) = - IndexdMinHeap::::children_index_range(position, heap_size) - .min_by_key(|&child_index| hole.get(child_index)) - { + if let Some(smallest_child) = IndexdMinHeap::::children_index_range(position, heap_size).min_by_key(|&child_index| hole.get(child_index)) { if hole.get(smallest_child) >= hole.element() { self.positions[hole.element().as_index()] = position; return; // no child is smaller @@ -218,11 +215,7 @@ impl<'a, T> Hole<'a, T> { unsafe fn new(data: &'a mut [T], pos: usize) -> Self { debug_assert!(pos < data.len()); let elt = ptr::read(&data[pos]); - Hole { - data, - elt: Some(elt), - pos, - } + Hole { data, elt: Some(elt), pos } } /// Returns a reference to the element removed. diff --git a/src/io.rs b/src/io.rs index 52057af..3c4d732 100644 --- a/src/io.rs +++ b/src/io.rs @@ -51,7 +51,7 @@ impl DataBytes for [T] { impl DataBytes for Vec { fn data_bytes(&self) -> &[u8] { - &self[..].data_bytes() + self[..].data_bytes() } }