Skip to content

Commit 2b50af0

Browse files
committed
clippy::must_use_candidate
1 parent 92f62ba commit 2b50af0

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ pub use http_types::{self as http, Body, Error, Status, StatusCode};
227227
/// #
228228
/// # Ok(()) }) }
229229
/// ```
230+
#[must_use]
230231
pub fn new() -> server::Server<()> {
231232
Server::new()
232233
}

src/log/middleware.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct LogMiddleware {
1919

2020
impl LogMiddleware {
2121
/// Create a new instance of `LogMiddleware`.
22+
#[must_use]
2223
pub fn new() -> Self {
2324
Self { _priv: () }
2425
}

src/middleware.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct Next<'a, State> {
4747

4848
impl<'a, State: 'static> Next<'a, State> {
4949
/// Asynchronously execute the remaining middleware chain.
50+
#[must_use]
5051
pub fn run(mut self, req: Request<State>) -> BoxFuture<'a, crate::Result> {
5152
if let Some((current, next)) = self.next_middleware.split_first() {
5253
self.next_middleware = next;

src/request.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl<State> Request<State> {
5959
/// #
6060
/// # Ok(()) })}
6161
/// ```
62+
#[must_use]
6263
pub fn method(&self) -> Method {
6364
self.request.method()
6465
}
@@ -82,6 +83,7 @@ impl<State> Request<State> {
8283
/// #
8384
/// # Ok(()) })}
8485
/// ```
86+
#[must_use]
8587
pub fn uri(&self) -> &Url {
8688
self.request.url()
8789
}
@@ -105,6 +107,7 @@ impl<State> Request<State> {
105107
/// #
106108
/// # Ok(()) })}
107109
/// ```
110+
#[must_use]
108111
pub fn version(&self) -> Option<Version> {
109112
self.request.version()
110113
}
@@ -128,6 +131,7 @@ impl<State> Request<State> {
128131
/// #
129132
/// # Ok(()) })}
130133
/// ```
134+
#[must_use]
131135
pub fn header(
132136
&self,
133137
key: &http_types::headers::HeaderName,
@@ -136,6 +140,7 @@ impl<State> Request<State> {
136140
}
137141

138142
/// Get a local value.
143+
#[must_use]
139144
pub fn local<T: Send + Sync + 'static>(&self) -> Option<&T> {
140145
self.request.local().get()
141146
}
@@ -146,6 +151,7 @@ impl<State> Request<State> {
146151
self
147152
}
148153

154+
#[must_use]
149155
/// Access app-global state.
150156
pub fn state(&self) -> &State {
151157
&self.state
@@ -293,6 +299,7 @@ impl<State> Request<State> {
293299
}
294300

295301
/// returns a `Cookie` by name of the cookie.
302+
#[must_use]
296303
pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> {
297304
let cookie_data = self
298305
.local::<CookieData>()
@@ -303,6 +310,7 @@ impl<State> Request<State> {
303310
}
304311

305312
/// Get the length of the body.
313+
#[must_use]
306314
pub fn len(&self) -> Option<usize> {
307315
self.request.len()
308316
}

src/response.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct Response {
2525

2626
impl Response {
2727
/// Create a new instance.
28+
#[must_use]
2829
pub fn new(status: StatusCode) -> Self {
2930
let res = http_types::Response::new(status);
3031
Self {
@@ -72,22 +73,26 @@ impl Response {
7273
}
7374

7475
/// Returns the statuscode.
76+
#[must_use]
7577
pub fn status(&self) -> crate::StatusCode {
7678
self.res.status()
7779
}
7880

7981
/// Set the statuscode.
82+
#[must_use]
8083
pub fn set_status(mut self, status: crate::StatusCode) -> Self {
8184
self.res.set_status(status);
8285
self
8386
}
8487

8588
/// Get the length of the body.
89+
#[must_use]
8690
pub fn len(&self) -> Option<usize> {
8791
self.res.len()
8892
}
8993

9094
/// Get an HTTP header.
95+
#[must_use]
9196
pub fn header(&self, name: &HeaderName) -> Option<&Vec<HeaderValue>> {
9297
self.res.header(name)
9398
}
@@ -126,6 +131,7 @@ impl Response {
126131
/// Set the request MIME.
127132
///
128133
/// [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)
134+
#[must_use]
129135
pub fn set_mime(self, mime: Mime) -> Self {
130136
self.set_header(http_types::headers::CONTENT_TYPE, format!("{}", mime))
131137
}
@@ -135,6 +141,7 @@ impl Response {
135141
/// # Mime
136142
///
137143
/// The encoding is set to `text/plain; charset=utf-8`.
144+
#[must_use]
138145
pub fn body_string(mut self, string: String) -> Self {
139146
self.res.set_body(string);
140147
self.set_mime(mime::TEXT_PLAIN_UTF_8)
@@ -221,6 +228,7 @@ impl Response {
221228
}
222229

223230
/// Get a local value.
231+
#[must_use]
224232
pub fn local<T: Send + Sync + 'static>(&self) -> Option<&T> {
225233
self.res.local().get()
226234
}

src/route.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl<'a, State: 'static> Route<'a, State> {
6060
}
6161

6262
/// Get the current path.
63+
#[must_use]
6364
pub fn path(&self) -> &str {
6465
&self.path
6566
}

src/security/cors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{Request, Result};
1414
/// use http_types::headers::HeaderValue;
1515
/// use tide::security::{CorsMiddleware, Origin};
1616
///
17-
/// CorsMiddleware::new()
17+
/// let cors = CorsMiddleware::new()
1818
/// .allow_methods("GET, POST, OPTIONS".parse::<HeaderValue>().unwrap())
1919
/// .allow_origin(Origin::from("*"))
2020
/// .allow_credentials(false);
@@ -35,6 +35,7 @@ pub const WILDCARD: &str = "*";
3535

3636
impl CorsMiddleware {
3737
/// Creates a new Cors middleware.
38+
#[must_use]
3839
pub fn new() -> Self {
3940
Self {
4041
allow_credentials: None,
@@ -47,6 +48,7 @@ impl CorsMiddleware {
4748
}
4849

4950
/// Set allow_credentials and return new Cors
51+
#[must_use]
5052
pub fn allow_credentials(mut self, allow_credentials: bool) -> Self {
5153
self.allow_credentials = match allow_credentials.to_string().parse() {
5254
Ok(header) => Some(header),

src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ impl Server<()> {
150150
/// #
151151
/// # Ok(()) }) }
152152
/// ```
153+
#[must_use]
153154
pub fn new() -> Server<()> {
154155
Self::with_state(())
155156
}

0 commit comments

Comments
 (0)