From 759f85e6686e3da240939314c54b48b28ade5dfa Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Fri, 25 Jun 2021 15:40:53 +0300 Subject: [PATCH] Revert adding #[must_use] --- CHANGES.md | 2 -- actix-http/CHANGES.md | 2 -- actix-http/src/body/body.rs | 1 - actix-http/src/builder.rs | 1 - actix-http/src/client/connector.rs | 1 - actix-http/src/config.rs | 10 --------- actix-http/src/extensions.rs | 3 --- actix-http/src/h1/client.rs | 7 ------ actix-http/src/h1/codec.rs | 6 ----- actix-http/src/h1/payload.rs | 2 -- actix-http/src/header/map.rs | 8 ------- .../src/header/shared/content_encoding.rs | 3 --- actix-http/src/message.rs | 2 -- actix-http/src/request.rs | 1 - actix-http/src/response.rs | 6 ----- actix-http/src/response_builder.rs | 2 -- actix-http/src/service.rs | 1 - actix-http/src/ws/codec.rs | 3 --- actix-http/src/ws/frame.rs | 1 - actix-http/src/ws/proto.rs | 1 - src/app.rs | 1 - src/config.rs | 6 ----- src/data.rs | 2 -- src/error/error.rs | 3 --- src/guard.rs | 11 ---------- src/http/header/accept.rs | 7 ------ src/http/header/content_disposition.rs | 19 ---------------- src/http/header/content_type.rs | 8 ------- src/http/header/date.rs | 1 - src/http/header/entity.rs | 8 ------- src/info.rs | 4 ---- src/middleware/compress.rs | 1 - src/request.rs | 18 --------------- src/response/builder.rs | 1 - src/response/http_codes.rs | 1 - src/response/response.rs | 3 --- src/rmap.rs | 1 - src/route.rs | 2 -- src/scope.rs | 1 - src/service.rs | 22 ------------------- src/test.rs | 8 ------- src/types/form.rs | 3 --- src/types/json.rs | 4 ---- src/types/payload.rs | 4 ---- src/web.rs | 13 ----------- 45 files changed, 215 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9ddc25984..7866e24b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,6 @@ ### Changed * Change compression algorithm features flags. [#2250] * Deprecate `App::data` and `App::data_factory`. [#2271] -* Add `#[must_use]` attribute for many public functions/methods. [#2281] ### Fixed @@ -21,7 +20,6 @@ [#2271]: https://github.com/actix/actix-web/pull/2271 [#2262]: https://github.com/actix/actix-web/pull/2262 [#2263]: https://github.com/actix/actix-web/pull/2263 -[#2281]: https://github.com/actix/actix-web/pull/2281 [#2288]: https://github.com/actix/actix-web/pull/2288 diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 5d917d43f..435607463 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -3,14 +3,12 @@ ## Unreleased - 2021-xx-xx ### Changed * Change compression algorithm features flags. [#2250] -* Add `#[must_use]` attribute for many public functions/methods. [#2281] ### Removed * `downcast` and `downcast_get_type_id` macros. [#2291] [#2291]: https://github.com/actix/actix-web/pull/2291 [#2250]: https://github.com/actix/actix-web/pull/2250 -[#2281]: https://github.com/actix/actix-web/pull/2281 ## 3.0.0-beta.7 - 2021-06-17 diff --git a/actix-http/src/body/body.rs b/actix-http/src/body/body.rs index 9c5934e9a..f04837d07 100644 --- a/actix-http/src/body/body.rs +++ b/actix-http/src/body/body.rs @@ -32,7 +32,6 @@ pub enum AnyBody { impl AnyBody { /// Create body from slice (copy) - #[must_use] pub fn from_slice(s: &[u8]) -> Self { Self::Bytes(Bytes::copy_from_slice(s)) } diff --git a/actix-http/src/builder.rs b/actix-http/src/builder.rs index 724077358..4e68dc920 100644 --- a/actix-http/src/builder.rs +++ b/actix-http/src/builder.rs @@ -36,7 +36,6 @@ where >::Future: 'static, { /// Create instance of `ServiceConfigBuilder` - #[must_use] pub fn new() -> Self { HttpServiceBuilder { keep_alive: KeepAlive::Timeout(5), diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 187a72138..bd46919e8 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -64,7 +64,6 @@ pub struct Connector { impl Connector<()> { #[allow(clippy::new_ret_no_self, clippy::let_unit_value)] - #[must_use] pub fn new() -> Connector< impl Service< TcpConnect, diff --git a/actix-http/src/config.rs b/actix-http/src/config.rs index bc934b50e..0e01e8748 100644 --- a/actix-http/src/config.rs +++ b/actix-http/src/config.rs @@ -68,7 +68,6 @@ impl Default for ServiceConfig { impl ServiceConfig { /// Create instance of `ServiceConfig` - #[must_use] pub fn new( keep_alive: KeepAlive, client_timeout: u64, @@ -100,35 +99,30 @@ impl ServiceConfig { /// Returns true if connection is secure (HTTPS) #[inline] - #[must_use] pub fn secure(&self) -> bool { self.0.secure } /// Returns the local address that this server is bound to. #[inline] - #[must_use] pub fn local_addr(&self) -> Option { self.0.local_addr } /// Keep alive duration if configured. #[inline] - #[must_use] pub fn keep_alive(&self) -> Option { self.0.keep_alive } /// Return state of connection keep-alive functionality #[inline] - #[must_use] pub fn keep_alive_enabled(&self) -> bool { self.0.ka_enabled } /// Client timeout for first request. #[inline] - #[must_use] pub fn client_timer(&self) -> Option { let delay_time = self.0.client_timeout; if delay_time != 0 { @@ -139,7 +133,6 @@ impl ServiceConfig { } /// Client timeout for first request. - #[must_use] pub fn client_timer_expire(&self) -> Option { let delay = self.0.client_timeout; if delay != 0 { @@ -150,7 +143,6 @@ impl ServiceConfig { } /// Client disconnect timer - #[must_use] pub fn client_disconnect_timer(&self) -> Option { let delay = self.0.client_disconnect; if delay != 0 { @@ -162,13 +154,11 @@ impl ServiceConfig { /// Return keep-alive timer delay is configured. #[inline] - #[must_use] pub fn keep_alive_timer(&self) -> Option { self.keep_alive().map(|ka| sleep_until(self.now() + ka)) } /// Keep-alive expire time - #[must_use] pub fn keep_alive_expire(&self) -> Option { self.keep_alive().map(|ka| self.now() + ka) } diff --git a/actix-http/src/extensions.rs b/actix-http/src/extensions.rs index 991e41258..5fdcefd6d 100644 --- a/actix-http/src/extensions.rs +++ b/actix-http/src/extensions.rs @@ -18,7 +18,6 @@ pub struct Extensions { impl Extensions { /// Creates an empty `Extensions`. #[inline] - #[must_use] pub fn new() -> Extensions { Extensions { map: AHashMap::default(), @@ -53,7 +52,6 @@ impl Extensions { /// assert_eq!(map.insert(1u32), None); /// assert!(map.contains::()); /// ``` - #[must_use] pub fn contains(&self) -> bool { self.map.contains_key(&TypeId::of::()) } @@ -66,7 +64,6 @@ impl Extensions { /// map.insert(1u32); /// assert_eq!(map.get::(), Some(&1u32)); /// ``` - #[must_use] pub fn get(&self) -> Option<&T> { self.map .get(&TypeId::of::()) diff --git a/actix-http/src/h1/client.rs b/actix-http/src/h1/client.rs index 325764404..4a6104688 100644 --- a/actix-http/src/h1/client.rs +++ b/actix-http/src/h1/client.rs @@ -53,7 +53,6 @@ impl ClientCodec { /// Create HTTP/1 codec. /// /// `keepalive_enabled` how response `connection` header get generated. - #[must_use] pub fn new(config: ServiceConfig) -> Self { let flags = if config.keep_alive_enabled() { Flags::KEEPALIVE_ENABLED @@ -75,19 +74,16 @@ impl ClientCodec { } /// Check if request is upgrade - #[must_use] pub fn upgrade(&self) -> bool { self.inner.ctype == ConnectionType::Upgrade } /// Check if last response is keep-alive - #[must_use] pub fn keepalive(&self) -> bool { self.inner.ctype == ConnectionType::KeepAlive } /// Check last request's message type - #[must_use] pub fn message_type(&self) -> MessageType { if self.inner.flags.contains(Flags::STREAM) { MessageType::Stream @@ -99,7 +95,6 @@ impl ClientCodec { } /// Convert message codec to a payload codec - #[must_use] pub fn into_payload_codec(self) -> ClientPayloadCodec { ClientPayloadCodec { inner: self.inner } } @@ -107,13 +102,11 @@ impl ClientCodec { impl ClientPayloadCodec { /// Check if last response is keep-alive - #[must_use] pub fn keepalive(&self) -> bool { self.inner.ctype == ConnectionType::KeepAlive } /// Transform payload codec to a message codec - #[must_use] pub fn into_message_codec(self) -> ClientCodec { ClientCodec { inner: self.inner } } diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index db221a7f0..634ca25e8 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -52,7 +52,6 @@ impl Codec { /// Create HTTP/1 codec. /// /// `keepalive_enabled` how response `connection` header get generated. - #[must_use] pub fn new(config: ServiceConfig) -> Self { let flags = if config.keep_alive_enabled() { Flags::KEEPALIVE_ENABLED @@ -73,28 +72,24 @@ impl Codec { /// Check if request is upgrade. #[inline] - #[must_use] pub fn upgrade(&self) -> bool { self.ctype == ConnectionType::Upgrade } /// Check if last response is keep-alive. #[inline] - #[must_use] pub fn keepalive(&self) -> bool { self.ctype == ConnectionType::KeepAlive } /// Check if keep-alive enabled on server level. #[inline] - #[must_use] pub fn keepalive_enabled(&self) -> bool { self.flags.contains(Flags::KEEPALIVE_ENABLED) } /// Check last request's message type. #[inline] - #[must_use] pub fn message_type(&self) -> MessageType { if self.flags.contains(Flags::STREAM) { MessageType::Stream @@ -106,7 +101,6 @@ impl Codec { } #[inline] - #[must_use] pub fn config(&self) -> &ServiceConfig { &self.config } diff --git a/actix-http/src/h1/payload.rs b/actix-http/src/h1/payload.rs index 24f6283fe..cc771f28a 100644 --- a/actix-http/src/h1/payload.rs +++ b/actix-http/src/h1/payload.rs @@ -41,7 +41,6 @@ impl Payload { /// * `PayloadSender` - *Sender* side of the stream /// /// * `Payload` - *Receiver* side of the stream - #[must_use] pub fn create(eof: bool) -> (PayloadSender, Payload) { let shared = Rc::new(RefCell::new(Inner::new(eof))); @@ -55,7 +54,6 @@ impl Payload { /// Create empty payload #[doc(hidden)] - #[must_use] pub fn empty() -> Payload { Payload { inner: Rc::new(RefCell::new(Inner::new(true))), diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index eabc2d277..634d9282f 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -81,7 +81,6 @@ impl HeaderMap { /// assert!(map.is_empty()); /// assert_eq!(0, map.capacity()); /// ``` - #[must_use] pub fn new() -> Self { HeaderMap::default() } @@ -99,7 +98,6 @@ impl HeaderMap { /// assert!(map.is_empty()); /// assert!(map.capacity() >= 16); /// ``` - #[must_use] pub fn with_capacity(capacity: usize) -> Self { HeaderMap { inner: AHashMap::with_capacity(capacity), @@ -152,7 +150,6 @@ impl HeaderMap { /// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2")); /// assert_eq!(map.len(), 3); /// ``` - #[must_use] pub fn len(&self) -> usize { self.inner .iter() @@ -176,7 +173,6 @@ impl HeaderMap { /// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2")); /// assert_eq!(map.len_keys(), 2); /// ``` - #[must_use] pub fn len_keys(&self) -> usize { self.inner.len() } @@ -192,7 +188,6 @@ impl HeaderMap { /// map.insert(header::ACCEPT, HeaderValue::from_static("text/plain")); /// assert!(!map.is_empty()); /// ``` - #[must_use] pub fn is_empty(&self) -> bool { self.inner.len() == 0 } @@ -439,7 +434,6 @@ impl HeaderMap { /// assert!(map.is_empty()); /// assert!(map.capacity() >= 16); /// ``` - #[must_use] pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -495,7 +489,6 @@ impl HeaderMap { /// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("one=1")))); /// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("two=2")))); /// ``` - #[must_use] pub fn iter(&self) -> Iter<'_> { Iter::new(self.inner.iter()) } @@ -522,7 +515,6 @@ impl HeaderMap { /// assert!(keys.contains(&header::HOST)); /// assert!(keys.contains(&header::SET_COOKIE)); /// ``` - #[must_use] pub fn keys(&self) -> Keys<'_> { Keys(self.inner.keys()) } diff --git a/actix-http/src/header/shared/content_encoding.rs b/actix-http/src/header/shared/content_encoding.rs index 8e1c78144..b9c1d2795 100644 --- a/actix-http/src/header/shared/content_encoding.rs +++ b/actix-http/src/header/shared/content_encoding.rs @@ -33,14 +33,12 @@ pub enum ContentEncoding { impl ContentEncoding { /// Is the content compressed? #[inline] - #[must_use] pub fn is_compression(self) -> bool { matches!(self, ContentEncoding::Identity | ContentEncoding::Auto) } /// Convert content encoding to string #[inline] - #[must_use] pub fn as_str(self) -> &'static str { match self { ContentEncoding::Br => "br", @@ -53,7 +51,6 @@ impl ContentEncoding { /// Default Q-factor (quality) value. #[inline] - #[must_use] pub fn quality(self) -> f64 { match self { ContentEncoding::Br => 1.1, diff --git a/actix-http/src/message.rs b/actix-http/src/message.rs index 6712a4b13..e85d686b7 100644 --- a/actix-http/src/message.rs +++ b/actix-http/src/message.rs @@ -234,7 +234,6 @@ pub struct ResponseHead { impl ResponseHead { /// Create new instance of `ResponseHead` type #[inline] - #[must_use] pub fn new(status: StatusCode) -> ResponseHead { ResponseHead { status, @@ -355,7 +354,6 @@ pub struct Message { impl Message { /// Get new message from the pool of objects - #[must_use] pub fn new() -> Self { T::with_pool(MessagePool::get_message) } diff --git a/actix-http/src/request.rs b/actix-http/src/request.rs index 7ac0da200..09c6dd296 100644 --- a/actix-http/src/request.rs +++ b/actix-http/src/request.rs @@ -57,7 +57,6 @@ impl From> for Request { impl Request { /// Create new Request instance - #[must_use] pub fn new() -> Request { Request { head: Message::new(), diff --git a/actix-http/src/response.rs b/actix-http/src/response.rs index 1d105cff4..2aa38c153 100644 --- a/actix-http/src/response.rs +++ b/actix-http/src/response.rs @@ -25,7 +25,6 @@ pub struct Response { impl Response { /// Constructs a new response with default body. #[inline] - #[must_use] pub fn new(status: StatusCode) -> Self { Response { head: BoxedResponseHead::new(status), @@ -35,7 +34,6 @@ impl Response { /// Constructs a new response builder. #[inline] - #[must_use] pub fn build(status: StatusCode) -> ResponseBuilder { ResponseBuilder::new(status) } @@ -45,28 +43,24 @@ impl Response { /// Constructs a new response with status 200 OK. #[inline] - #[must_use] pub fn ok() -> Self { Response::new(StatusCode::OK) } /// Constructs a new response with status 400 Bad Request. #[inline] - #[must_use] pub fn bad_request() -> Self { Response::new(StatusCode::BAD_REQUEST) } /// Constructs a new response with status 404 Not Found. #[inline] - #[must_use] pub fn not_found() -> Self { Response::new(StatusCode::NOT_FOUND) } /// Constructs a new response with status 500 Internal Server Error. #[inline] - #[must_use] pub fn internal_server_error() -> Self { Response::new(StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/actix-http/src/response_builder.rs b/actix-http/src/response_builder.rs index 124b5864d..e46d9a28c 100644 --- a/actix-http/src/response_builder.rs +++ b/actix-http/src/response_builder.rs @@ -62,7 +62,6 @@ impl ResponseBuilder { /// assert_eq!(res.status(), StatusCode::OK); /// ``` #[inline] - #[must_use] pub fn new(status: StatusCode) -> Self { ResponseBuilder { head: Some(BoxedResponseHead::new(status)), @@ -221,7 +220,6 @@ impl ResponseBuilder { /// Responses extensions #[inline] - #[must_use] pub fn extensions(&self) -> Ref<'_, Extensions> { let head = self.head.as_ref().expect("cannot reuse response builder"); head.extensions.borrow() diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index 13a00b61d..afe47bf2d 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -47,7 +47,6 @@ where B: MessageBody + 'static, { /// Create builder for `HttpService` instance. - #[must_use] pub fn build() -> HttpServiceBuilder { HttpServiceBuilder::new() } diff --git a/actix-http/src/ws/codec.rs b/actix-http/src/ws/codec.rs index ab1a50695..8655216fa 100644 --- a/actix-http/src/ws/codec.rs +++ b/actix-http/src/ws/codec.rs @@ -80,7 +80,6 @@ bitflags! { impl Codec { /// Create new WebSocket frames decoder. - #[must_use] pub const fn new() -> Codec { Codec { max_size: 65_536, @@ -91,7 +90,6 @@ impl Codec { /// Set max frame size. /// /// By default max size is set to 64kB. - #[must_use] pub fn max_size(mut self, size: usize) -> Self { self.max_size = size; self @@ -100,7 +98,6 @@ impl Codec { /// Set decoder to client mode. /// /// By default decoder works in server mode. - #[must_use] pub fn client_mode(mut self) -> Self { self.flags.remove(Flags::SERVER); self diff --git a/actix-http/src/ws/frame.rs b/actix-http/src/ws/frame.rs index 3e9d302ea..46edf5d85 100644 --- a/actix-http/src/ws/frame.rs +++ b/actix-http/src/ws/frame.rs @@ -139,7 +139,6 @@ impl Parser { } /// Parse the payload of a close frame. - #[must_use] pub fn parse_close_payload(payload: &[u8]) -> Option { if payload.len() >= 2 { let raw_code = u16::from_be_bytes(TryFrom::try_from(&payload[..2]).unwrap()); diff --git a/actix-http/src/ws/proto.rs b/actix-http/src/ws/proto.rs index 137485c45..fdcde5eac 100644 --- a/actix-http/src/ws/proto.rs +++ b/actix-http/src/ws/proto.rs @@ -226,7 +226,6 @@ static WS_GUID: &[u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; /// Hashes the `Sec-WebSocket-Key` header according to the WebSocket spec. /// /// Result is a Base64 encoded byte array. `base64(sha1(input))` is always 28 bytes. -#[must_use] pub fn hash_key(key: &[u8]) -> [u8; 28] { let hash = { use sha1::Digest as _; diff --git a/src/app.rs b/src/app.rs index 6c4782245..5cff20568 100644 --- a/src/app.rs +++ b/src/app.rs @@ -42,7 +42,6 @@ pub struct App { impl App { /// Create application builder. Application can be configured with a builder-like pattern. #[allow(clippy::new_without_default)] - #[must_use] pub fn new() -> Self { let factory_ref = Rc::new(RefCell::new(None)); diff --git a/src/config.rs b/src/config.rs index bdd90a15b..884128308 100644 --- a/src/config.rs +++ b/src/config.rs @@ -44,7 +44,6 @@ impl AppService { } /// Check if root is being configured - #[must_use] pub fn is_root(&self) -> bool { self.root } @@ -75,13 +74,11 @@ impl AppService { } /// Returns reference to configuration. - #[must_use] pub fn config(&self) -> &AppConfig { &self.config } /// Returns default handler factory. - #[must_use] pub fn default_service(&self) -> Rc { self.default.clone() } @@ -134,19 +131,16 @@ impl AppConfig { /// documentation for more information. /// /// By default host name is set to a "localhost" value. - #[must_use] pub fn host(&self) -> &str { &self.host } /// Returns true if connection is secure(https) - #[must_use] pub fn secure(&self) -> bool { self.secure } /// Returns the socket address of the local half of this TCP connection - #[must_use] pub fn local_addr(&self) -> SocketAddr { self.addr } diff --git a/src/data.rs b/src/data.rs index ac101282c..174faba37 100644 --- a/src/data.rs +++ b/src/data.rs @@ -77,13 +77,11 @@ impl Data { } /// Get reference to inner app data. - #[must_use] pub fn get_ref(&self) -> &T { self.0.as_ref() } /// Convert to the internal Arc - #[must_use] pub fn into_inner(self) -> Arc { self.0 } diff --git a/src/error/error.rs b/src/error/error.rs index 50408cf06..add290867 100644 --- a/src/error/error.rs +++ b/src/error/error.rs @@ -20,19 +20,16 @@ pub struct Error { impl Error { /// Returns the reference to the underlying `ResponseError`. - #[must_use] pub fn as_response_error(&self) -> &dyn ResponseError { self.cause.as_ref() } /// Similar to `as_response_error` but downcasts. - #[must_use] pub fn as_error(&self) -> Option<&T> { ::downcast_ref(self.cause.as_ref()) } /// Shortcut for creating an `HttpResponse`. - #[must_use] pub fn error_response(&self) -> HttpResponse { self.cause.error_response() } diff --git a/src/guard.rs b/src/guard.rs index 2f4459e3e..c71d64a29 100644 --- a/src/guard.rs +++ b/src/guard.rs @@ -195,68 +195,57 @@ impl Guard for MethodGuard { } /// Guard to match *GET* HTTP method. -#[must_use] pub fn Get() -> MethodGuard { MethodGuard(http::Method::GET) } /// Predicate to match *POST* HTTP method. -#[must_use] pub fn Post() -> MethodGuard { MethodGuard(http::Method::POST) } /// Predicate to match *PUT* HTTP method. -#[must_use] pub fn Put() -> MethodGuard { MethodGuard(http::Method::PUT) } /// Predicate to match *DELETE* HTTP method. -#[must_use] pub fn Delete() -> MethodGuard { MethodGuard(http::Method::DELETE) } /// Predicate to match *HEAD* HTTP method. -#[must_use] pub fn Head() -> MethodGuard { MethodGuard(http::Method::HEAD) } /// Predicate to match *OPTIONS* HTTP method. -#[must_use] pub fn Options() -> MethodGuard { MethodGuard(http::Method::OPTIONS) } /// Predicate to match *CONNECT* HTTP method. -#[must_use] pub fn Connect() -> MethodGuard { MethodGuard(http::Method::CONNECT) } /// Predicate to match *PATCH* HTTP method. -#[must_use] pub fn Patch() -> MethodGuard { MethodGuard(http::Method::PATCH) } /// Predicate to match *TRACE* HTTP method. -#[must_use] pub fn Trace() -> MethodGuard { MethodGuard(http::Method::TRACE) } /// Predicate to match specified HTTP method. -#[must_use] pub fn Method(method: http::Method) -> MethodGuard { MethodGuard(method) } /// Return predicate that matches if request contains specified header and /// value. -#[must_use] pub fn Header(name: &'static str, value: &'static str) -> HeaderGuard { HeaderGuard( header::HeaderName::try_from(name).unwrap(), diff --git a/src/http/header/accept.rs b/src/http/header/accept.rs index b7a6522eb..75366dfae 100644 --- a/src/http/header/accept.rs +++ b/src/http/header/accept.rs @@ -126,31 +126,26 @@ crate::http::header::common_header! { impl Accept { /// Construct `Accept: */*`. - #[must_use] pub fn star() -> Accept { Accept(vec![qitem(mime::STAR_STAR)]) } /// Construct `Accept: application/json`. - #[must_use] pub fn json() -> Accept { Accept(vec![qitem(mime::APPLICATION_JSON)]) } /// Construct `Accept: text/*`. - #[must_use] pub fn text() -> Accept { Accept(vec![qitem(mime::TEXT_STAR)]) } /// Construct `Accept: image/*`. - #[must_use] pub fn image() -> Accept { Accept(vec![qitem(mime::IMAGE_STAR)]) } /// Construct `Accept: text/html`. - #[must_use] pub fn html() -> Accept { Accept(vec![qitem(mime::TEXT_HTML)]) } @@ -159,7 +154,6 @@ impl Accept { /// [q-factor weighting] and specificity. /// /// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2 - #[must_use] pub fn mime_precedence(&self) -> Vec { let mut types = self.0.clone(); @@ -210,7 +204,6 @@ impl Accept { /// Returns `None` if contained list is empty. /// /// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2 - #[must_use] pub fn mime_preference(&self) -> Option { let types = self.mime_precedence(); types.first().cloned() diff --git a/src/http/header/content_disposition.rs b/src/http/header/content_disposition.rs index c81ae8389..9f67baffb 100644 --- a/src/http/header/content_disposition.rs +++ b/src/http/header/content_disposition.rs @@ -101,28 +101,24 @@ pub enum DispositionParam { impl DispositionParam { /// Returns `true` if the parameter is [`Name`](DispositionParam::Name). #[inline] - #[must_use] pub fn is_name(&self) -> bool { self.as_name().is_some() } /// Returns `true` if the parameter is [`Filename`](DispositionParam::Filename). #[inline] - #[must_use] pub fn is_filename(&self) -> bool { self.as_filename().is_some() } /// Returns `true` if the parameter is [`FilenameExt`](DispositionParam::FilenameExt). #[inline] - #[must_use] pub fn is_filename_ext(&self) -> bool { self.as_filename_ext().is_some() } /// Returns `true` if the parameter is [`Unknown`](DispositionParam::Unknown) and the `name` #[inline] - #[must_use] /// matches. pub fn is_unknown>(&self, name: T) -> bool { self.as_unknown(name).is_some() @@ -131,14 +127,12 @@ impl DispositionParam { /// Returns `true` if the parameter is [`UnknownExt`](DispositionParam::UnknownExt) and the /// `name` matches. #[inline] - #[must_use] pub fn is_unknown_ext>(&self, name: T) -> bool { self.as_unknown_ext(name).is_some() } /// Returns the name if applicable. #[inline] - #[must_use] pub fn as_name(&self) -> Option<&str> { match self { DispositionParam::Name(ref name) => Some(name.as_str()), @@ -148,7 +142,6 @@ impl DispositionParam { /// Returns the filename if applicable. #[inline] - #[must_use] pub fn as_filename(&self) -> Option<&str> { match self { DispositionParam::Filename(ref filename) => Some(filename.as_str()), @@ -158,7 +151,6 @@ impl DispositionParam { /// Returns the filename* if applicable. #[inline] - #[must_use] pub fn as_filename_ext(&self) -> Option<&ExtendedValue> { match self { DispositionParam::FilenameExt(ref value) => Some(value), @@ -169,7 +161,6 @@ impl DispositionParam { /// Returns the value of the unrecognized regular parameter if it is /// [`Unknown`](DispositionParam::Unknown) and the `name` matches. #[inline] - #[must_use] pub fn as_unknown>(&self, name: T) -> Option<&str> { match self { DispositionParam::Unknown(ref ext_name, ref value) @@ -184,7 +175,6 @@ impl DispositionParam { /// Returns the value of the unrecognized extended parameter if it is /// [`Unknown`](DispositionParam::Unknown) and the `name` matches. #[inline] - #[must_use] pub fn as_unknown_ext>(&self, name: T) -> Option<&ExtendedValue> { match self { DispositionParam::UnknownExt(ref ext_name, ref value) @@ -396,25 +386,21 @@ impl ContentDisposition { } /// Returns `true` if it is [`Inline`](DispositionType::Inline). - #[must_use] pub fn is_inline(&self) -> bool { matches!(self.disposition, DispositionType::Inline) } /// Returns `true` if it is [`Attachment`](DispositionType::Attachment). - #[must_use] pub fn is_attachment(&self) -> bool { matches!(self.disposition, DispositionType::Attachment) } /// Returns `true` if it is [`FormData`](DispositionType::FormData). - #[must_use] pub fn is_form_data(&self) -> bool { matches!(self.disposition, DispositionType::FormData) } /// Returns `true` if it is [`Ext`](DispositionType::Ext) and the `disp_type` matches. - #[must_use] pub fn is_ext(&self, disp_type: impl AsRef) -> bool { matches!( self.disposition, @@ -423,13 +409,11 @@ impl ContentDisposition { } /// Return the value of *name* if exists. - #[must_use] pub fn get_name(&self) -> Option<&str> { self.parameters.iter().find_map(DispositionParam::as_name) } /// Return the value of *filename* if exists. - #[must_use] pub fn get_filename(&self) -> Option<&str> { self.parameters .iter() @@ -437,7 +421,6 @@ impl ContentDisposition { } /// Return the value of *filename\** if exists. - #[must_use] pub fn get_filename_ext(&self) -> Option<&ExtendedValue> { self.parameters .iter() @@ -445,14 +428,12 @@ impl ContentDisposition { } /// Return the value of the parameter which the `name` matches. - #[must_use] pub fn get_unknown(&self, name: impl AsRef) -> Option<&str> { let name = name.as_ref(); self.parameters.iter().find_map(|p| p.as_unknown(name)) } /// Return the value of the extended parameter which the `name` matches. - #[must_use] pub fn get_unknown_ext(&self, name: impl AsRef) -> Option<&ExtendedValue> { let name = name.as_ref(); self.parameters.iter().find_map(|p| p.as_unknown_ext(name)) diff --git a/src/http/header/content_type.rs b/src/http/header/content_type.rs index e9587505b..e1c419c22 100644 --- a/src/http/header/content_type.rs +++ b/src/http/header/content_type.rs @@ -63,7 +63,6 @@ impl ContentType { /// A constructor to easily create a `Content-Type: application/json` /// header. #[inline] - #[must_use] pub fn json() -> ContentType { ContentType(mime::APPLICATION_JSON) } @@ -71,21 +70,18 @@ impl ContentType { /// A constructor to easily create a `Content-Type: text/plain; /// charset=utf-8` header. #[inline] - #[must_use] pub fn plaintext() -> ContentType { ContentType(mime::TEXT_PLAIN_UTF_8) } /// A constructor to easily create a `Content-Type: text/html` header. #[inline] - #[must_use] pub fn html() -> ContentType { ContentType(mime::TEXT_HTML) } /// A constructor to easily create a `Content-Type: text/xml` header. #[inline] - #[must_use] pub fn xml() -> ContentType { ContentType(mime::TEXT_XML) } @@ -93,21 +89,18 @@ impl ContentType { /// A constructor to easily create a `Content-Type: /// application/www-form-url-encoded` header. #[inline] - #[must_use] pub fn form_url_encoded() -> ContentType { ContentType(mime::APPLICATION_WWW_FORM_URLENCODED) } /// A constructor to easily create a `Content-Type: image/jpeg` header. #[inline] - #[must_use] pub fn jpeg() -> ContentType { ContentType(mime::IMAGE_JPEG) } /// A constructor to easily create a `Content-Type: image/png` header. #[inline] - #[must_use] pub fn png() -> ContentType { ContentType(mime::IMAGE_PNG) } @@ -115,7 +108,6 @@ impl ContentType { /// A constructor to easily create a `Content-Type: /// application/octet-stream` header. #[inline] - #[must_use] pub fn octet_stream() -> ContentType { ContentType(mime::APPLICATION_OCTET_STREAM) } diff --git a/src/http/header/date.rs b/src/http/header/date.rs index 25b7ad611..4d1717886 100644 --- a/src/http/header/date.rs +++ b/src/http/header/date.rs @@ -38,7 +38,6 @@ crate::http::header::common_header! { impl Date { /// Create a date instance set to the current system time - #[must_use] pub fn now() -> Date { Date(SystemTime::now().into()) } diff --git a/src/http/header/entity.rs b/src/http/header/entity.rs index 8084966b4..5073ed692 100644 --- a/src/http/header/entity.rs +++ b/src/http/header/entity.rs @@ -58,7 +58,6 @@ impl EntityTag { /// Constructs a new EntityTag. /// # Panics /// If the tag contains invalid characters. - #[must_use] pub fn new(weak: bool, tag: String) -> EntityTag { assert!(check_slice_validity(&tag), "Invalid tag: {:?}", tag); EntityTag { weak, tag } @@ -67,7 +66,6 @@ impl EntityTag { /// Constructs a new weak EntityTag. /// # Panics /// If the tag contains invalid characters. - #[must_use] pub fn weak(tag: String) -> EntityTag { EntityTag::new(true, tag) } @@ -75,13 +73,11 @@ impl EntityTag { /// Constructs a new strong EntityTag. /// # Panics /// If the tag contains invalid characters. - #[must_use] pub fn strong(tag: String) -> EntityTag { EntityTag::new(false, tag) } /// Get the tag. - #[must_use] pub fn tag(&self) -> &str { self.tag.as_ref() } @@ -96,7 +92,6 @@ impl EntityTag { /// For strong comparison two entity-tags are equivalent if both are not /// weak and their opaque-tags match character-by-character. - #[must_use] pub fn strong_eq(&self, other: &EntityTag) -> bool { !self.weak && !other.weak && self.tag == other.tag } @@ -104,19 +99,16 @@ impl EntityTag { /// For weak comparison two entity-tags are equivalent if their /// opaque-tags match character-by-character, regardless of either or /// both being tagged as "weak". - #[must_use] pub fn weak_eq(&self, other: &EntityTag) -> bool { self.tag == other.tag } /// The inverse of `EntityTag.strong_eq()`. - #[must_use] pub fn strong_ne(&self, other: &EntityTag) -> bool { !self.strong_eq(other) } /// The inverse of `EntityTag.weak_eq()`. - #[must_use] pub fn weak_ne(&self, other: &EntityTag) -> bool { !self.weak_eq(other) } diff --git a/src/info.rs b/src/info.rs index 7f74ad860..93151bbd2 100644 --- a/src/info.rs +++ b/src/info.rs @@ -161,7 +161,6 @@ impl ConnectionInfo { /// - X-Forwarded-Proto /// - Uri #[inline] - #[must_use] pub fn scheme(&self) -> &str { &self.scheme } @@ -175,7 +174,6 @@ impl ConnectionInfo { /// - Host /// - Uri /// - Server hostname - #[must_use] pub fn host(&self) -> &str { &self.host } @@ -183,7 +181,6 @@ impl ConnectionInfo { /// remote_addr address of the request. /// /// Get remote_addr address from socket address - #[must_use] pub fn remote_addr(&self) -> Option<&str> { self.remote_addr.as_ref().map(String::as_ref) } @@ -201,7 +198,6 @@ impl ConnectionInfo { /// address explicitly, use /// [`HttpRequest::peer_addr()`](super::web::HttpRequest::peer_addr()) instead. #[inline] - #[must_use] pub fn realip_remote_addr(&self) -> Option<&str> { if let Some(ref r) = self.realip_remote_addr { Some(r) diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index 2e651bbf0..a9128bc47 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -43,7 +43,6 @@ pub struct Compress(ContentEncoding); impl Compress { /// Create new `Compress` middleware with the specified encoding. - #[must_use] pub fn new(encoding: ContentEncoding) -> Self { Compress(encoding) } diff --git a/src/request.rs b/src/request.rs index b61affd7e..0248571b1 100644 --- a/src/request.rs +++ b/src/request.rs @@ -65,7 +65,6 @@ impl HttpRequest { impl HttpRequest { /// This method returns reference to the request head #[inline] - #[must_use] pub fn head(&self) -> &RequestHead { &self.inner.head } @@ -79,27 +78,23 @@ impl HttpRequest { /// Request's uri. #[inline] - #[must_use] pub fn uri(&self) -> &Uri { &self.head().uri } /// Read the Request method. #[inline] - #[must_use] pub fn method(&self) -> &Method { &self.head().method } /// Read the Request Version. #[inline] - #[must_use] pub fn version(&self) -> Version { self.head().version } #[inline] - #[must_use] /// Returns request's headers. pub fn headers(&self) -> &HeaderMap { &self.head().headers @@ -107,7 +102,6 @@ impl HttpRequest { /// The target path of this Request. #[inline] - #[must_use] pub fn path(&self) -> &str { self.head().uri.path() } @@ -116,7 +110,6 @@ impl HttpRequest { /// /// E.g., id=10 #[inline] - #[must_use] pub fn query_string(&self) -> &str { self.uri().query().unwrap_or_default() } @@ -128,7 +121,6 @@ impl HttpRequest { /// where the identifier can be used later in a request handler to /// access the matched value for that segment. #[inline] - #[must_use] pub fn match_info(&self) -> &Path { &self.inner.path } @@ -145,7 +137,6 @@ impl HttpRequest { /// /// Returns a None when no resource is fully matched, including default services. #[inline] - #[must_use] pub fn match_pattern(&self) -> Option { self.resource_map().match_pattern(self.path()) } @@ -154,21 +145,18 @@ impl HttpRequest { /// /// Returns a None when no resource is fully matched, including default services. #[inline] - #[must_use] pub fn match_name(&self) -> Option<&str> { self.resource_map().match_name(self.path()) } /// Request extensions #[inline] - #[must_use] pub fn extensions(&self) -> Ref<'_, Extensions> { self.head().extensions() } /// Mutable reference to a the request's extensions #[inline] - #[must_use] pub fn extensions_mut(&self) -> RefMut<'_, Extensions> { self.head().extensions_mut() } @@ -209,7 +197,6 @@ impl HttpRequest { } #[inline] - #[must_use] /// Get a reference to a `ResourceMap` of current application. pub fn resource_map(&self) -> &ResourceMap { &self.app_state().rmap() @@ -224,7 +211,6 @@ impl HttpRequest { /// /// Will only return None when called in unit tests. #[inline] - #[must_use] pub fn peer_addr(&self) -> Option { self.head().peer_addr } @@ -234,14 +220,12 @@ impl HttpRequest { /// This method panics if request's extensions container is already /// borrowed. #[inline] - #[must_use] pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> { ConnectionInfo::get(self.head(), self.app_config()) } /// App config #[inline] - #[must_use] pub fn app_config(&self) -> &AppConfig { self.app_state().config() } @@ -254,7 +238,6 @@ impl HttpRequest { /// ```ignore /// let opt_t = req.app_data::>(); /// ``` - #[must_use] pub fn app_data(&self) -> Option<&T> { for container in self.inner.app_data.iter().rev() { if let Some(data) = container.get::() { @@ -295,7 +278,6 @@ impl HttpRequest { /// Return request cookie. #[cfg(feature = "cookies")] - #[must_use] pub fn cookie(&self, name: &str) -> Option> { if let Ok(cookies) = self.cookies() { for cookie in cookies.iter() { diff --git a/src/response/builder.rs b/src/response/builder.rs index c77da2adb..56d30d9d0 100644 --- a/src/response/builder.rs +++ b/src/response/builder.rs @@ -42,7 +42,6 @@ pub struct HttpResponseBuilder { impl HttpResponseBuilder { #[inline] /// Create response builder - #[must_use] pub fn new(status: StatusCode) -> Self { Self { res: Some(Response::new(status)), diff --git a/src/response/http_codes.rs b/src/response/http_codes.rs index 2b131be3b..d67ef3f92 100644 --- a/src/response/http_codes.rs +++ b/src/response/http_codes.rs @@ -7,7 +7,6 @@ use crate::{HttpResponse, HttpResponseBuilder}; macro_rules! static_resp { ($name:ident, $status:expr) => { #[allow(non_snake_case, missing_docs)] - #[must_use] pub fn $name() -> HttpResponseBuilder { HttpResponseBuilder::new($status) } diff --git a/src/response/response.rs b/src/response/response.rs index fb943c70c..ceeb43437 100644 --- a/src/response/response.rs +++ b/src/response/response.rs @@ -33,13 +33,11 @@ pub struct HttpResponse { impl HttpResponse { /// Create HTTP response builder with specific status. #[inline] - #[must_use] pub fn build(status: StatusCode) -> HttpResponseBuilder { HttpResponseBuilder::new(status) } /// Create a response. - #[must_use] #[inline] pub fn new(status: StatusCode) -> Self { Self { @@ -50,7 +48,6 @@ impl HttpResponse { /// Create an error response. #[inline] - #[must_use] pub fn from_error(error: impl Into) -> Self { let error = error.into(); let mut response = error.as_response_error().error_response(); diff --git a/src/rmap.rs b/src/rmap.rs index 0dc4e1b01..3c8805d57 100644 --- a/src/rmap.rs +++ b/src/rmap.rs @@ -17,7 +17,6 @@ pub struct ResourceMap { } impl ResourceMap { - #[must_use] pub fn new(root: ResourceDef) -> Self { ResourceMap { root, diff --git a/src/route.rs b/src/route.rs index 86ee3038c..d85b940bd 100644 --- a/src/route.rs +++ b/src/route.rs @@ -28,7 +28,6 @@ pub struct Route { impl Route { /// Create new route which matches any request. #[allow(clippy::new_without_default)] - #[must_use] pub fn new() -> Route { Route { service: boxed::factory(HandlerService::new(HttpResponse::NotFound)), @@ -102,7 +101,6 @@ impl Route { /// ); /// # } /// ``` - #[must_use] pub fn method(mut self, method: Method) -> Self { Rc::get_mut(&mut self.guards) .unwrap() diff --git a/src/scope.rs b/src/scope.rs index a26c82078..aa546c422 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -65,7 +65,6 @@ pub struct Scope { impl Scope { /// Create a new scope - #[must_use] pub fn new(path: &str) -> Scope { let factory_ref = Rc::new(RefCell::new(None)); diff --git a/src/service.rs b/src/service.rs index 9e9f9986a..c1bffac49 100644 --- a/src/service.rs +++ b/src/service.rs @@ -75,7 +75,6 @@ impl ServiceRequest { /// Deconstruct request into parts #[inline] - #[must_use] pub fn into_parts(self) -> (HttpRequest, Payload) { (self.req, self.payload) } @@ -87,7 +86,6 @@ impl ServiceRequest { } /// Construct request from parts. - #[must_use] pub fn from_parts(req: HttpRequest, payload: Payload) -> Self { Self { req, payload } } @@ -95,7 +93,6 @@ impl ServiceRequest { /// Construct request from request. /// /// The returned `ServiceRequest` would have no payload. - #[must_use] pub fn from_request(req: HttpRequest) -> Self { ServiceRequest { req, @@ -119,7 +116,6 @@ impl ServiceRequest { /// This method returns reference to the request head #[inline] - #[must_use] pub fn head(&self) -> &RequestHead { &self.req.head() } @@ -132,34 +128,29 @@ impl ServiceRequest { /// Request's uri. #[inline] - #[must_use] pub fn uri(&self) -> &Uri { &self.head().uri } /// Read the Request method. #[inline] - #[must_use] pub fn method(&self) -> &Method { &self.head().method } /// Read the Request Version. #[inline] - #[must_use] pub fn version(&self) -> Version { self.head().version } #[inline] - #[must_use] /// Returns request's headers. pub fn headers(&self) -> &HeaderMap { &self.head().headers } #[inline] - #[must_use] /// Returns mutable request's headers. pub fn headers_mut(&mut self) -> &mut HeaderMap { &mut self.head_mut().headers @@ -167,7 +158,6 @@ impl ServiceRequest { /// The target path of this Request. #[inline] - #[must_use] pub fn path(&self) -> &str { self.head().uri.path() } @@ -176,7 +166,6 @@ impl ServiceRequest { /// /// E.g., id=10 #[inline] - #[must_use] pub fn query_string(&self) -> &str { self.uri().query().unwrap_or_default() } @@ -190,14 +179,12 @@ impl ServiceRequest { /// /// Will only return None when called in unit tests. #[inline] - #[must_use] pub fn peer_addr(&self) -> Option { self.head().peer_addr } /// Get *ConnectionInfo* for the current request. #[inline] - #[must_use] pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> { ConnectionInfo::get(self.head(), &*self.app_config()) } @@ -209,34 +196,29 @@ impl ServiceRequest { /// where the identifier can be used later in a request handler to /// access the matched value for that segment. #[inline] - #[must_use] pub fn match_info(&self) -> &Path { self.req.match_info() } /// Counterpart to [`HttpRequest::match_name`](super::HttpRequest::match_name()). #[inline] - #[must_use] pub fn match_name(&self) -> Option<&str> { self.req.match_name() } /// Counterpart to [`HttpRequest::match_pattern`](super::HttpRequest::match_pattern()). #[inline] - #[must_use] pub fn match_pattern(&self) -> Option { self.req.match_pattern() } #[inline] - #[must_use] /// Get a mutable reference to the Path parameters. pub fn match_info_mut(&mut self) -> &mut Path { self.req.match_info_mut() } #[inline] - #[must_use] /// Get a reference to a `ResourceMap` of current application. pub fn resource_map(&self) -> &ResourceMap { self.req.resource_map() @@ -244,13 +226,11 @@ impl ServiceRequest { /// Service configuration #[inline] - #[must_use] pub fn app_config(&self) -> &AppConfig { self.req.app_config() } /// Counterpart to [`HttpRequest::app_data`](super::HttpRequest::app_data()). - #[must_use] pub fn app_data(&self) -> Option<&T> { for container in self.req.inner.app_data.iter().rev() { if let Some(data) = container.get::() { @@ -268,7 +248,6 @@ impl ServiceRequest { /// Return request cookie. #[cfg(feature = "cookies")] - #[must_use] pub fn cookie(&self, name: &str) -> Option> { self.req.cookie(name) } @@ -497,7 +476,6 @@ impl WebService { /// Set service name. /// /// Name is used for url generation. - #[must_use] pub fn name(mut self, name: &str) -> Self { self.name = Some(name.to_string()); self diff --git a/src/test.rs b/src/test.rs index 54326d0d0..05a4ba7f2 100644 --- a/src/test.rs +++ b/src/test.rs @@ -31,14 +31,12 @@ use crate::{ }; /// Create service that always responds with `HttpResponse::Ok()` and no body. -#[must_use] pub fn ok_service( ) -> impl Service, Error = Error> { default_service(StatusCode::OK) } /// Create service that always responds with given status code and no body. -#[must_use] pub fn default_service( status_code: StatusCode, ) -> impl Service, Error = Error> { @@ -400,37 +398,31 @@ impl Default for TestRequest { #[allow(clippy::wrong_self_convention)] impl TestRequest { /// Create TestRequest and set request uri - #[must_use] pub fn with_uri(path: &str) -> TestRequest { TestRequest::default().uri(path) } /// Create TestRequest and set method to `Method::GET` - #[must_use] pub fn get() -> TestRequest { TestRequest::default().method(Method::GET) } /// Create TestRequest and set method to `Method::POST` - #[must_use] pub fn post() -> TestRequest { TestRequest::default().method(Method::POST) } /// Create TestRequest and set method to `Method::PUT` - #[must_use] pub fn put() -> TestRequest { TestRequest::default().method(Method::PUT) } /// Create TestRequest and set method to `Method::PATCH` - #[must_use] pub fn patch() -> TestRequest { TestRequest::default().method(Method::PATCH) } /// Create TestRequest and set method to `Method::DELETE` - #[must_use] pub fn delete() -> TestRequest { TestRequest::default().method(Method::DELETE) } diff --git a/src/types/form.rs b/src/types/form.rs index 9c852f34f..c81f73554 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -228,14 +228,12 @@ pub struct FormConfig { impl FormConfig { /// Set maximum accepted payload size. By default this limit is 16kB. - #[must_use] pub fn limit(mut self, limit: usize) -> Self { self.limit = limit; self } /// Set custom error handler - #[must_use] pub fn error_handler(mut self, f: F) -> Self where F: Fn(UrlencodedError, &HttpRequest) -> Error + 'static, @@ -332,7 +330,6 @@ impl UrlEncoded { } /// Set maximum accepted payload size. The default limit is 256kB. - #[must_use] pub fn limit(mut self, limit: usize) -> Self { self.limit = limit; self diff --git a/src/types/json.rs b/src/types/json.rs index f1323dbcd..fc02c8854 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -241,14 +241,12 @@ pub struct JsonConfig { impl JsonConfig { /// Set maximum accepted payload size. By default this limit is 2MB. - #[must_use] pub fn limit(mut self, limit: usize) -> Self { self.limit = limit; self } /// Set custom error handler. - #[must_use] pub fn error_handler(mut self, f: F) -> Self where F: Fn(JsonPayloadError, &HttpRequest) -> Error + Send + Sync + 'static, @@ -258,7 +256,6 @@ impl JsonConfig { } /// Set predicate for allowed content types. - #[must_use] pub fn content_type(mut self, predicate: F) -> Self where F: Fn(mime::Mime) -> bool + Send + Sync + 'static, @@ -368,7 +365,6 @@ where } /// Set maximum accepted payload size. The default limit is 2MB. - #[must_use] pub fn limit(self, limit: usize) -> Self { match self { JsonBody::Body { diff --git a/src/types/payload.rs b/src/types/payload.rs index 2295afb7a..188da6201 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -47,7 +47,6 @@ pub struct Payload(pub crate::dev::Payload); impl Payload { /// Unwrap to inner Payload type. - #[must_use] pub fn into_inner(self) -> crate::dev::Payload { self.0 } @@ -215,7 +214,6 @@ pub struct PayloadConfig { impl PayloadConfig { /// Create new instance with a size limit (in bytes) and no mime type condition. - #[must_use] pub fn new(limit: usize) -> Self { Self { limit, @@ -224,14 +222,12 @@ impl PayloadConfig { } /// Set maximum accepted payload size in bytes. The default limit is 256kB. - #[must_use] pub fn limit(mut self, limit: usize) -> Self { self.limit = limit; self } /// Set required mime type of the request. By default mime type is not enforced. - #[must_use] pub fn mimetype(mut self, mt: Mime) -> Self { self.mimetype = Some(mt); self diff --git a/src/web.rs b/src/web.rs index 0e27ad6b9..40ac46275 100644 --- a/src/web.rs +++ b/src/web.rs @@ -51,7 +51,6 @@ pub use crate::types::*; /// .route(web::head().to(|| HttpResponse::MethodNotAllowed())) /// ); /// ``` -#[must_use] pub fn resource(path: T) -> Resource { Resource::new(path) } @@ -77,13 +76,11 @@ pub fn resource(path: T) -> Resource { /// * /{project_id}/path2 /// * /{project_id}/path3 /// -#[must_use] pub fn scope(path: &str) -> Scope { Scope::new(path) } /// Create *route* without configuration. -#[must_use] pub fn route() -> Route { Route::new() } @@ -102,7 +99,6 @@ pub fn route() -> Route { /// In the above example, one `GET` route gets added: /// * /{project_id} /// -#[must_use] pub fn get() -> Route { method(Method::GET) } @@ -121,7 +117,6 @@ pub fn get() -> Route { /// In the above example, one `POST` route gets added: /// * /{project_id} /// -#[must_use] pub fn post() -> Route { method(Method::POST) } @@ -140,7 +135,6 @@ pub fn post() -> Route { /// In the above example, one `PUT` route gets added: /// * /{project_id} /// -#[must_use] pub fn put() -> Route { method(Method::PUT) } @@ -159,7 +153,6 @@ pub fn put() -> Route { /// In the above example, one `PATCH` route gets added: /// * /{project_id} /// -#[must_use] pub fn patch() -> Route { method(Method::PATCH) } @@ -178,7 +171,6 @@ pub fn patch() -> Route { /// In the above example, one `DELETE` route gets added: /// * /{project_id} /// -#[must_use] pub fn delete() -> Route { method(Method::DELETE) } @@ -197,7 +189,6 @@ pub fn delete() -> Route { /// In the above example, one `HEAD` route gets added: /// * /{project_id} /// -#[must_use] pub fn head() -> Route { method(Method::HEAD) } @@ -216,7 +207,6 @@ pub fn head() -> Route { /// In the above example, one `HEAD` route gets added: /// * /{project_id} /// -#[must_use] pub fn trace() -> Route { method(Method::TRACE) } @@ -235,7 +225,6 @@ pub fn trace() -> Route { /// In the above example, one `GET` route gets added: /// * /{project_id} /// -#[must_use] pub fn method(method: Method) -> Route { Route::new().method(method) } @@ -254,7 +243,6 @@ pub fn method(method: Method) -> Route { /// web::to(index)) /// ); /// ``` -#[must_use] pub fn to(handler: F) -> Route where F: Handler, @@ -280,7 +268,6 @@ where /// .finish(my_service) /// ); /// ``` -#[must_use] pub fn service(path: T) -> WebService { WebService::new(path) }