diff --git a/actix-http/benches/quality-value.rs b/actix-http/benches/quality-value.rs index 31b67f999..33ba9c4c8 100644 --- a/actix-http/benches/quality-value.rs +++ b/actix-http/benches/quality-value.rs @@ -42,32 +42,37 @@ mod _new { if x < 10 { f.write_str("00")?; // 0 is handled so it's not possible to have a trailing 0, we can just return - itoa::fmt(f, x) + itoa_fmt(f, x) } else if x < 100 { f.write_str("0")?; if x % 10 == 0 { // trailing 0, divide by 10 and write - itoa::fmt(f, x / 10) + itoa_fmt(f, x / 10) } else { - itoa::fmt(f, x) + itoa_fmt(f, x) } } else { // x is in range 101–999 if x % 100 == 0 { // two trailing 0s, divide by 100 and write - itoa::fmt(f, x / 100) + itoa_fmt(f, x / 100) } else if x % 10 == 0 { // one trailing 0, divide by 10 and write - itoa::fmt(f, x / 10) + itoa_fmt(f, x / 10) } else { - itoa::fmt(f, x) + itoa_fmt(f, x) } } } } } } + + pub fn itoa_fmt(mut wr: W, value: V) -> fmt::Result { + let mut buf = itoa::Buffer::new(); + wr.write_str(buf.format(value)) + } } mod _naive { diff --git a/src/config.rs b/src/config.rs index 2482ee6c4..77fba18ed 100644 --- a/src/config.rs +++ b/src/config.rs @@ -299,38 +299,6 @@ mod tests { assert_eq!(resp.status(), StatusCode::OK); } - // #[actix_rt::test] - // async fn test_data_factory() { - // let cfg = |cfg: &mut ServiceConfig| { - // cfg.data_factory(|| { - // sleep(std::time::Duration::from_millis(50)).then(|_| { - // println!("READY"); - // Ok::<_, ()>(10usize) - // }) - // }); - // }; - - // let srv = - // init_service(App::new().configure(cfg).service( - // web::resource("/").to(|_: web::Data| HttpResponse::Ok()), - // )); - // let req = TestRequest::default().to_request(); - // let resp = srv.call(req).await.unwrap(); - // assert_eq!(resp.status(), StatusCode::OK); - - // let cfg2 = |cfg: &mut ServiceConfig| { - // cfg.data_factory(|| Ok::<_, ()>(10u32)); - // }; - // let srv = init_service( - // App::new() - // .service(web::resource("/").to(|_: web::Data| HttpResponse::Ok())) - // .configure(cfg2), - // ); - // let req = TestRequest::default().to_request(); - // let resp = srv.call(req).await.unwrap(); - // assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR); - // } - #[actix_rt::test] async fn test_external_resource() { let srv = init_service(