From eefe8b0733118d0cc8d6ddeafddace79f0d4baca Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sat, 16 Dec 2023 10:08:45 +0000 Subject: [PATCH 1/5] Implement From for http::HeaderMap (#3222) * Implement From for http::HeaderMap * Update changelog * Apply clippy fix * doc tweak --------- Co-authored-by: SleeplessOne1917 Co-authored-by: Rob Ede --- actix-http/CHANGES.md | 1 + actix-http/src/header/map.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index fc49bc931..eadd5c515 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -5,6 +5,7 @@ ### Changed - Updated `zstd` dependency to `0.13`. +- Implemented `From` for `http::HeaderMap`. ### Fixed diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index e8118be93..d8a63b573 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -636,10 +636,17 @@ impl<'a> IntoIterator for &'a HeaderMap { } } -/// Convert `http::HeaderMap` to our `HeaderMap`. +/// Convert a `http::HeaderMap` to our `HeaderMap`. impl From for HeaderMap { - fn from(mut map: http::HeaderMap) -> HeaderMap { - HeaderMap::from_drain(map.drain()) + fn from(mut map: http::HeaderMap) -> Self { + Self::from_drain(map.drain()) + } +} + +/// Convert our `HeaderMap` to a `http::HeaderMap`. +impl From for http::HeaderMap { + fn from(map: HeaderMap) -> Self { + Self::from_iter(map) } } From c7a0af31d3bb05f08e2b22100d8c835273d029f1 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 16 Dec 2023 10:20:28 +0000 Subject: [PATCH 2/5] docs: doc and metadata tweaks --- actix-http/Cargo.toml | 2 +- actix-http/README.md | 10 +++++++--- actix-http/src/lib.rs | 3 ++- actix-router/src/resource.rs | 4 ++-- actix-web/Cargo.toml | 2 +- actix-web/src/redirect.rs | 2 +- scripts/bump | 5 ++++- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index f483ea093..8476d9086 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -5,7 +5,7 @@ authors = [ "Nikolay Kim ", "Rob Ede ", ] -description = "HTTP primitives for the Actix ecosystem" +description = "HTTP types and services for the Actix ecosystem" keywords = ["actix", "http", "framework", "async", "futures"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-web" diff --git a/actix-http/README.md b/actix-http/README.md index 049de9278..7d499f4b3 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -1,6 +1,8 @@ -# actix-http +# `actix-http` -> HTTP primitives for the Actix ecosystem. +> HTTP types and services for the Actix ecosystem. + + [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) [![Documentation](https://docs.rs/actix-http/badge.svg?version=3.4.0)](https://docs.rs/actix-http/3.4.0) @@ -11,12 +13,14 @@ [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-http) - Minimum Supported Rust Version (MSRV): 1.68 -## Example +## Examples ```rust use std::{env, io}; diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index 382295fbc..976697ca6 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -1,6 +1,7 @@ -//! HTTP primitives for the Actix ecosystem. +//! HTTP types and services for the Actix ecosystem. //! //! ## Crate Features +//! //! | Feature | Functionality | //! | ------------------- | ------------------------------------------- | //! | `http2` | HTTP/2 support via [h2]. | diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index 80c0a2d68..abd132211 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -193,8 +193,8 @@ const REGEX_FLAGS: &str = "(?s-m)"; /// # Trailing Slashes /// It should be noted that this library takes no steps to normalize intra-path or trailing slashes. /// As such, all resource definitions implicitly expect a pre-processing step to normalize paths if -/// they you wish to accommodate "recoverable" path errors. Below are several examples of -/// resource-path pairs that would not be compatible. +/// you wish to accommodate "recoverable" path errors. Below are several examples of resource-path +/// pairs that would not be compatible. /// /// ## Examples /// ``` diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index c9aab17b2..d9cf0b94f 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -15,7 +15,7 @@ categories = [ ] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-web" -license = "MIT OR Apache-2.0" +license.workspace = true edition.workspace = true rust-version.workspace = true diff --git a/actix-web/src/redirect.rs b/actix-web/src/redirect.rs index f9e9f2d7a..5ce960aa4 100644 --- a/actix-web/src/redirect.rs +++ b/actix-web/src/redirect.rs @@ -171,7 +171,7 @@ impl Responder for Redirect { } else { log::error!( "redirect target location can not be converted to header value: {:?}", - self.to + self.to, ); } diff --git a/scripts/bump b/scripts/bump index baf3fb4d8..9d90542c6 100755 --- a/scripts/bump +++ b/scripts/bump @@ -93,9 +93,12 @@ fi # done; remove backup files rm -f $CARGO_MANIFEST.bak -rm -f $CHANGELOG_FILE.bak rm -f $README_FILE.bak +if [ -n "${CHANGELOG_FILE-}" ]; then + rm -f $CHANGELOG_FILE.bak +fi + echo "manifest, changelog, and readme updated" echo echo "check other references:" From 5e5e5d8315791cda46a3d02a392f18c391e8179e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 16 Dec 2023 10:26:32 +0000 Subject: [PATCH 3/5] chore: remove allow(uninlined_format_args) --- actix-files/src/lib.rs | 1 - actix-http-test/src/lib.rs | 1 - actix-http/benches/response-body-compression.rs | 2 -- actix-http/src/lib.rs | 3 +-- actix-http/tests/test_openssl.rs | 1 - actix-http/tests/test_ws.rs | 2 -- actix-multipart/src/lib.rs | 2 +- actix-router/benches/quoter.rs | 2 -- actix-router/src/lib.rs | 1 - actix-router/src/router.rs | 5 +++-- actix-web-actors/src/lib.rs | 1 - actix-web/benches/server.rs | 2 -- actix-web/examples/macroless.rs | 2 -- actix-web/examples/uds.rs | 2 -- actix-web/src/lib.rs | 1 - actix-web/tests/test_httpserver.rs | 2 -- awc/examples/client.rs | 2 -- awc/src/lib.rs | 3 +-- awc/tests/test_client.rs | 2 -- 19 files changed, 6 insertions(+), 31 deletions(-) diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 7871905f6..943130e16 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -13,7 +13,6 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible, missing_docs, missing_debug_implementations)] -#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-http-test/src/lib.rs b/actix-http-test/src/lib.rs index 2f1725d1c..554af9102 100644 --- a/actix-http-test/src/lib.rs +++ b/actix-http-test/src/lib.rs @@ -2,7 +2,6 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] -#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-http/benches/response-body-compression.rs b/actix-http/benches/response-body-compression.rs index d128bf75b..53279e312 100644 --- a/actix-http/benches/response-body-compression.rs +++ b/actix-http/benches/response-body-compression.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use std::convert::Infallible; use actix_http::{encoding::Encoder, ContentEncoding, Request, Response, StatusCode}; diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index 976697ca6..888c3e06f 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -22,8 +22,7 @@ #![allow( clippy::type_complexity, clippy::too_many_arguments, - clippy::borrow_interior_mutable_const, - clippy::uninlined_format_args + clippy::borrow_interior_mutable_const )] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] diff --git a/actix-http/tests/test_openssl.rs b/actix-http/tests/test_openssl.rs index b4d8ed1a5..cb16a4fec 100644 --- a/actix-http/tests/test_openssl.rs +++ b/actix-http/tests/test_openssl.rs @@ -1,5 +1,4 @@ #![cfg(feature = "openssl")] -#![allow(clippy::uninlined_format_args)] extern crate tls_openssl as openssl; diff --git a/actix-http/tests/test_ws.rs b/actix-http/tests/test_ws.rs index a2866613b..9a78074c4 100644 --- a/actix-http/tests/test_ws.rs +++ b/actix-http/tests/test_ws.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use std::{ cell::Cell, convert::Infallible, diff --git a/actix-multipart/src/lib.rs b/actix-multipart/src/lib.rs index 615a8e6de..495bae9c0 100644 --- a/actix-multipart/src/lib.rs +++ b/actix-multipart/src/lib.rs @@ -2,7 +2,7 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] -#![allow(clippy::borrow_interior_mutable_const, clippy::uninlined_format_args)] +#![allow(clippy::borrow_interior_mutable_const)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-router/benches/quoter.rs b/actix-router/benches/quoter.rs index c78240809..2428a767d 100644 --- a/actix-router/benches/quoter.rs +++ b/actix-router/benches/quoter.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use std::{borrow::Cow, fmt::Write as _}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; diff --git a/actix-router/src/lib.rs b/actix-router/src/lib.rs index 53c0ad82a..f10093436 100644 --- a/actix-router/src/lib.rs +++ b/actix-router/src/lib.rs @@ -2,7 +2,6 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] -#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-router/src/router.rs b/actix-router/src/router.rs index d31d10ce8..1dd4449da 100644 --- a/actix-router/src/router.rs +++ b/actix-router/src/router.rs @@ -97,6 +97,7 @@ impl RouterBuilder { ctx: U, ) -> (&mut ResourceDef, &mut T, &mut U) { self.routes.push((rdef, val, ctx)); + #[allow(clippy::map_identity)] // map is used to distribute &mut-ness to tuple elements self.routes .last_mut() .map(|(rdef, val, ctx)| (rdef, val, ctx)) @@ -186,11 +187,11 @@ mod tests { assert_eq!(path.get("file").unwrap(), "file"); assert_eq!(path.get("ext").unwrap(), "gz"); - let mut path = Path::new("/vtest/ttt/index.html"); + let mut path = Path::new("/v2/ttt/index.html"); let (h, info) = router.recognize_mut(&mut path).unwrap(); assert_eq!(*h, 14); assert_eq!(info, ResourceId(4)); - assert_eq!(path.get("val").unwrap(), "test"); + assert_eq!(path.get("val").unwrap(), "2"); assert_eq!(path.get("val2").unwrap(), "ttt"); let mut path = Path::new("/v/blah-blah/index.html"); diff --git a/actix-web-actors/src/lib.rs b/actix-web-actors/src/lib.rs index cf2eb3645..d89b0ee35 100644 --- a/actix-web-actors/src/lib.rs +++ b/actix-web-actors/src/lib.rs @@ -57,7 +57,6 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] -#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web/benches/server.rs b/actix-web/benches/server.rs index 2c9f71dc5..0d45c9403 100644 --- a/actix-web/benches/server.rs +++ b/actix-web/benches/server.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use actix_web::{web, App, HttpResponse}; use awc::Client; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/actix-web/examples/macroless.rs b/actix-web/examples/macroless.rs index d3589da21..78ffd45c1 100644 --- a/actix-web/examples/macroless.rs +++ b/actix-web/examples/macroless.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use actix_web::{middleware, rt, web, App, HttpRequest, HttpServer}; async fn index(req: HttpRequest) -> &'static str { diff --git a/actix-web/examples/uds.rs b/actix-web/examples/uds.rs index 15e28ba1d..e854bb3b1 100644 --- a/actix-web/examples/uds.rs +++ b/actix-web/examples/uds.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use actix_web::{get, web, HttpRequest}; #[cfg(unix)] use actix_web::{middleware, App, Error, HttpResponse, HttpServer}; diff --git a/actix-web/src/lib.rs b/actix-web/src/lib.rs index e982a43b1..88f0ae9be 100644 --- a/actix-web/src/lib.rs +++ b/actix-web/src/lib.rs @@ -69,7 +69,6 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] -#![allow(clippy::uninlined_format_args)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/actix-web/tests/test_httpserver.rs b/actix-web/tests/test_httpserver.rs index 861d76d93..86e0575f3 100644 --- a/actix-web/tests/test_httpserver.rs +++ b/actix-web/tests/test_httpserver.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - #[cfg(feature = "openssl")] extern crate tls_openssl as openssl; diff --git a/awc/examples/client.rs b/awc/examples/client.rs index 26edcfd62..16ad330b8 100644 --- a/awc/examples/client.rs +++ b/awc/examples/client.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use std::error::Error as StdError; #[tokio::main] diff --git a/awc/src/lib.rs b/awc/src/lib.rs index ce2dfb34f..253b5161a 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -105,8 +105,7 @@ #![allow( clippy::type_complexity, clippy::borrow_interior_mutable_const, - clippy::needless_doctest_main, - clippy::uninlined_format_args + clippy::needless_doctest_main )] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] diff --git a/awc/tests/test_client.rs b/awc/tests/test_client.rs index 6d1459ac0..76915630f 100644 --- a/awc/tests/test_client.rs +++ b/awc/tests/test_client.rs @@ -1,5 +1,3 @@ -#![allow(clippy::uninlined_format_args)] - use std::{ collections::HashMap, convert::Infallible, From 271edafd4de2616fa3f3e17949badb844412cc5d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 16 Dec 2023 10:37:19 +0000 Subject: [PATCH 4/5] docs: add router readme --- actix-router/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 actix-router/README.md diff --git a/actix-router/README.md b/actix-router/README.md new file mode 100644 index 000000000..15a449c44 --- /dev/null +++ b/actix-router/README.md @@ -0,0 +1,16 @@ +# `actix-router` + +[![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) +[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.1)](https://docs.rs/actix-router/0.5.1) +![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg) +
+[![dependency status](https://deps.rs/crate/actix-router/0.5.1/status.svg)](https://deps.rs/crate/actix-router/0.5.1) +[![Download](https://img.shields.io/crates/d/actix-router.svg)](https://crates.io/crates/actix-router) +[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + + +Resource path matching and router. + + From ede0201aa49edaf68f4e381906e524e437900bb7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 16 Dec 2023 10:42:16 +0000 Subject: [PATCH 5/5] docs: fix derive readme version --- actix-multipart-derive/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-multipart-derive/README.md b/actix-multipart-derive/README.md index 2737410f6..cd5780c56 100644 --- a/actix-multipart-derive/README.md +++ b/actix-multipart-derive/README.md @@ -3,11 +3,11 @@ > The derive macro implementation for actix-multipart-derive. [![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive) -[![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.5.0)](https://docs.rs/actix-multipart-derive/0.5.0) +[![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart-derive.svg)
-[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.5.0/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.5.0) +[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.6.1) [![Download](https://img.shields.io/crates/d/actix-multipart-derive.svg)](https://crates.io/crates/actix-multipart-derive) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)