clippy
cargo devel CI / cargo CI (push) Has been cancelled Details

This commit is contained in:
Christoph J. Scherr 2024-02-16 15:57:00 +01:00
parent 17da4f55f4
commit af40a5aec1
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
10 changed files with 31 additions and 28 deletions

View File

@ -291,7 +291,6 @@ fn main() {
} {
Some(inner) => {
println!("{:?}", inner);
return;
}
None => unreachable!(),
}

View File

@ -2,8 +2,8 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Through
use revsqrt::{fast_inverse_sqrt, regular_inverse_sqrt};
const SIZE: f32 = 1337.1337;
const FCONST: f32 = 1024.12481224;
const FCONST1: f32 = 4025.724812234;
const FCONST: f32 = 1_024.124_8;
const FCONST1: f32 = 4_025.724_9;
pub fn single_input(c: &mut Criterion) {
c.bench_with_input(BenchmarkId::new("regular rsqrt", SIZE), &SIZE, |b, &s| {

View File

@ -1,8 +1,8 @@
use std::iter::zip;
use revsqrt;
use rand;
// is n about the same as m?
// This is actually not so easy! How do you measure "about same"ness?
@ -34,14 +34,14 @@ fn test_calc_regular_rsqrt() {
#[test]
fn test_calc_specific_fast_rsqrt() {
let params: &[f32] = &[1.0, 1.1, 100.0, 1337.0, 123.45678900, 1337.1337];
let params: &[f32] = &[1.0, 1.1, 100.0, 1337.0, 123.456_79, 1337.1337];
let results: &[f32] = &[
1.0,
0.9534625892455922,
0.953_462_6,
0.1,
0.02734854943722097,
0.0900000004095,
0.027347182112297627,
0.027_348_55,
0.09,
0.027_347_183,
];
for (n, m) in zip(params, results) {
assert!(about_same(revsqrt::fast_inverse_sqrt(*n), *m))
@ -50,20 +50,21 @@ fn test_calc_specific_fast_rsqrt() {
#[test]
fn test_calc_specific_reqular_rsqrt() {
let params: &[f32] = &[1.0, 1.1, 100.0, 1337.0, 123.45678900, 1337.1337];
let params: &[f32] = &[1.0, 1.1, 100.0, 1337.0, 123.456_79, 1337.1337];
let results: &[f32] = &[
1.0,
0.9534625892455922,
0.953_462_6,
0.1,
0.02734854943722097,
0.0900000004095,
0.027347182112297627,
0.027_348_55,
0.09,
0.027_347_183,
];
for (n, m) in zip(params, results) {
assert_eq!(revsqrt::regular_inverse_sqrt(*n), *m)
}
}
#[allow(clippy::assertions_on_constants)]
#[test]
#[ignore] // this test confuses the CI
fn test_fail() {

View File

@ -1,9 +1,9 @@
use std::iter::zip;
use revsqrt;
use cucumber::{gherkin::Step, given, then, when, World};
use rand;
/// stores the current information for each scenario
#[derive(Debug, Default, World)]

View File

@ -1,7 +1,6 @@
use anyhow;
use chrono;
#![allow(clippy::disallowed_names)]
use serde::{Deserialize, Serialize};
use serde_json;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(rename_all = "UPPERCASE")]

View File

@ -6,17 +6,17 @@ use std::{
// This is just a very simple tcp server/client that connects to itself
const ADDR: &'static str = "127.0.0.1:9911";
const ADDR: &str = "127.0.0.1:9911";
fn main() -> Result<()> {
let mut listen = net::TcpListener::bind(ADDR)?;
let listen = net::TcpListener::bind(ADDR)?;
let mut client = net::TcpStream::connect(ADDR)?;
let mut sink = io::sink();
let _sink = io::sink();
client.write_all(b"foo")?;
let mut com = listen.accept()?;
com.0.write_all(b"bak")?;
let mut buf = [0;3];
client.read(&mut buf)?;
let mut buf = [0; 3];
let _ = client.read(&mut buf)?;
println!("{buf:x?}");
Ok(())
}

View File

@ -3,6 +3,7 @@ use std::{
thread,
};
#[allow(dead_code)]
struct WorkerThread {
handle: thread::JoinHandle<()>,
id: usize,
@ -24,6 +25,7 @@ impl WorkerThread {
/// Shares tasks over multiple worker threads
pub struct ThreadPool {
/// executes tasks assigned by the instructor
#[allow(dead_code)]
workers: Vec<WorkerThread>,
/// sends instructions to the workers
sender: mpsc::Sender<Job>,
@ -41,8 +43,8 @@ impl ThreadPool {
///
/// The `new` function will panic if the size is zero.
pub fn build(size: usize) -> Result<ThreadPool, String> {
if !(size > 0) {
return Err(format!("cannot build a thread pool with size 0!"));
if size == 0 {
return Err("cannot build a thread pool with size 0!".to_string());
}
let (sender, receiver) = mpsc::channel();
let receiver = Arc::new(Mutex::new(receiver));

View File

@ -12,7 +12,7 @@ async fn foo(t: TestType) -> Result<TcpListener, std::io::Error> {
#[tokio::main()]
async fn main() {
let testdata: TestType = 1337;
let arcmut = Arc::new(Mutex::new(testdata));
let _arcmut = Arc::new(Mutex::new(testdata));
tokio::spawn(async move {
let a = foo(testdata).await;
a.unwrap().accept().await

View File

@ -43,6 +43,7 @@ fn status(start: &Instant, info: (u128, usize), separate: usize) -> bool {
eq
}
#[allow(clippy::uninit_vec)]
#[tokio::main]
async fn main() {
// Lets say that we want to add many numbers FAST

View File

@ -1,3 +1,4 @@
#![allow(clippy::disallowed_names)]
fn main() {
println!(
"SUCCESS!!!