Skip to content

Commit

Permalink
Remove use types that have been imported by default (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn authored Feb 24, 2025
1 parent c2d9127 commit b16c67a
Show file tree
Hide file tree
Showing 30 changed files with 11 additions and 45 deletions.
1 change: 0 additions & 1 deletion crates/cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use std::borrow::Borrow;
use std::collections::VecDeque;
use std::error::Error as StdError;
use std::future::Future;
use std::hash::Hash;

use bytes::Bytes;
Expand Down
1 change: 0 additions & 1 deletion crates/compression/src/stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Compress the body of a response.
use std::collections::VecDeque;
use std::future::Future;
use std::io::{self, Error as IoError, ErrorKind, Result as IoResult};
use std::pin::Pin;
use std::task::{Context, Poll, ready};
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/conn/acme/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use std::error::Error as StdError;
use std::future::Future;
use std::io::{Error as IoError, ErrorKind, Result as IoResult};
use std::path::Path;

Expand Down
1 change: 0 additions & 1 deletion crates/core/src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! The module also provides support for HTTP versions 1 and 2, as well as the QUIC protocol.
//! Additionally, it includes implementations for Unix domain sockets.
use std::fmt::{self, Display, Formatter};
use std::future::Future;
use std::io::Result as IoResult;

use http::uri::Scheme;
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/conn/proto.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::cmp;
use std::error::Error as StdError;
use std::future::Future;
use std::io::{Error as IoError, ErrorKind, IoSlice, Result as IoResult};
use std::marker::PhantomPinned;
use std::pin::Pin;
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/conn/quinn/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Client implementation of the HTTP/3 protocol
use std::{
convert::TryFrom,
marker::PhantomData,
sync::{atomic::AtomicUsize, Arc},
task::{Context, Poll, Waker},
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/conn/stream/handshake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::future::Future;
use std::io::{Error as IoError, ErrorKind, Result as IoResult};
use std::pin::Pin;
use std::sync::Arc;
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mod case;
pub use case::RenameRule;

use std::fmt::Debug;
use std::future::Future;

use crate::Writer;
use crate::http::Request;
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod named_file;
pub use named_file::*;

use std::cmp;
use std::future::Future;
use std::io::{self, Error as IoError, ErrorKind, Read, Result as IoResult, Seek};
use std::pin::Pin;
use std::task::{Context, Poll, ready};
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/http/body/res.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::VecDeque;
use std::fmt::{self, Debug};
use std::future::Future;
use std::io::{Error as IoError, ErrorKind, Result as IoResult};
use std::pin::Pin;
use std::task::{self, Context, Poll, ready};
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub use response::Response;

pub use http::version::Version;

use std::future::Future;
use std::io::Result as IoResult;
use std::sync::Arc;

Expand Down
1 change: 0 additions & 1 deletion crates/core/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Server module
use std::future::Future;
use std::io::Result as IoResult;
#[cfg(feature = "server-handle")]
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;

Expand Down
2 changes: 0 additions & 2 deletions crates/core/src/test/request/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::borrow::Borrow;
use std::convert::TryInto;
use std::future::Future;
use std::str;
use std::sync::Arc;

Expand Down
1 change: 0 additions & 1 deletion crates/core/src/test/response.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::future::Future;
use std::io::{self, Result as IoResult, Write};

use bytes::{Bytes, BytesMut};
Expand Down
1 change: 0 additions & 1 deletion crates/csrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

use std::error::Error as StdError;
use std::future::Future;

mod finder;

Expand Down
2 changes: 0 additions & 2 deletions crates/extra/src/basic_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
//! Server::new(acceptor).serve(router).await;
//! }
//! ```
use std::future::Future;

use base64::engine::{general_purpose, Engine};
use salvo_core::http::header::{HeaderName, AUTHORIZATION, PROXY_AUTHORIZATION};
use salvo_core::http::{Request, Response, StatusCode};
Expand Down
1 change: 0 additions & 1 deletion crates/extra/src/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ use serde::Serialize;
use std::borrow::Cow;
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter, Write};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
Expand Down
1 change: 0 additions & 1 deletion crates/extra/src/tower_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//! ```
use std::error::Error as StdError;
use std::fmt;
use std::future::Future;
use std::io::{Error as IoError, ErrorKind};
use std::marker::PhantomData;
use std::sync::Arc;
Expand Down
1 change: 0 additions & 1 deletion crates/extra/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
//!```
use std::fmt::{self, Debug, Formatter};
use std::future::Future;
use std::pin::Pin;
use std::task::{ready, Context, Poll};

Expand Down
1 change: 0 additions & 1 deletion crates/flash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

use std::fmt::{self, Debug, Display, Formatter};
use std::future::Future;
use std::ops::Deref;

use salvo_core::{Depot, FlowCtrl, Handler, Request, Response, async_trait};
Expand Down
1 change: 0 additions & 1 deletion crates/jwt-auth/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use jsonwebtoken::errors::Error as JwtError;
use jsonwebtoken::{Algorithm, DecodingKey, TokenData, Validation, decode};
use serde::Deserialize;
use std::future::Future;

use salvo_core::Depot;

Expand Down
1 change: 0 additions & 1 deletion crates/jwt-auth/src/oidc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Oidc(OpenID Connect) supports.
use std::future::Future;
use std::str::FromStr;
use std::sync::Arc;
use std::time::SystemTime;
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi-macros/src/response/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl TryToTokens for ToResponses<'_> {
let ident = &self.ident;
let (impl_generics, ty_generics, where_clause) = self.generics.split_for_impl();

let responses = if responses.len() > 0 {
let responses = if !responses.is_empty() {
quote!( #responses.into())
} else {
quote!( #oapi::oapi::Responses::new())
Expand Down
14 changes: 7 additions & 7 deletions crates/oapi/docs/derive_to_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ The following attributes are available for use in on the container attribute `#[
deriving `ToParameters`:

* `names(...)` Define comma separated list of names for unnamed fields of struct used as a path parameter.
__Only__ supported on __unnamed structs__.
__Only__ supported on __unnamed structs__.
* `style = ...` Defines how all parameters are serialized by [`ParameterStyle`][style]. Default
values are based on _`parameter_in`_ attribute.
values are based on _`parameter_in`_ attribute.
* `default_parameter_in = ...` = Defines default where the parameters of this field are used with a value from
[`parameter::ParameterIn`][in_enum]. If this attribute is not supplied, then the default value is from query.
[`parameter::ParameterIn`][in_enum]. If this attribute is not supplied, then the default value is from query.
* `rename_all = ...` Can be provided to alternatively to the serde's `rename_all` attribute. Effectively provides same functionality.

Use `names` to define name for single unnamed argument.
Expand Down Expand Up @@ -62,7 +62,7 @@ The following attributes are available for use in the `#[salvo(parameter(...))]`
* `style = ...` Defines how the parameter is serialized by [`ParameterStyle`][style]. Default values are based on _`parameter_in`_ attribute.

* `parameter_in = ...` = Defines where the parameters of this field are used with a value from
[`parameter::ParameterIn`][in_enum]. If this attribute is not supplied, then the default value is from query.
[`parameter::ParameterIn`][in_enum]. If this attribute is not supplied, then the default value is from query.

* `explode` Defines whether new _`parameter=value`_ pair is created for each parameter within _`object`_ or _`array`_.

Expand All @@ -74,8 +74,8 @@ The following attributes are available for use in the `#[salvo(parameter(...))]`
* `value_type = ...` Can be used to override default type derived from type of the field used in OpenAPI spec.
This is useful in cases where the default type does not correspond to the actual type e.g. when
any third-party types are used which are not [`ToSchema`][to_schema]s nor [`primitive` types][primitive].
Value can be any Rust type what normally could be used to serialize to JSON or custom type such as _`Object`_.
_`Object`_ will be rendered as generic OpenAPI object.
Value can be any Rust type what normally could be used to serialize to JSON or custom type such as _`Object`_.
_`Object`_ will be rendered as generic OpenAPI object.

* `inline` If set, the schema for this field's type needs to be a [`ToSchema`][to_schema], and
the schema definition will be inlined.
Expand All @@ -93,7 +93,7 @@ The following attributes are available for use in the `#[salvo(parameter(...))]`
* `nullable` Defines property is nullable (note this is different to non-required).

* `required = ...` Can be used to enforce required status for the parameter. [See
rules][derive@ToParameters#field-nullability-and-required-rules]
rules][derive@ToParameters#field-nullability-and-required-rules]

* `rename = ...` Can be provided to alternatively to the serde's `rename` attribute. Effectively provides same functionality.

Expand Down
4 changes: 2 additions & 2 deletions crates/oapi/docs/endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ _**Example request body definitions.**_
_`serde_json::json!`_ can parse as a _`serde_json::Value`_.

* `response = ...` Type what implements [`ToResponse`][to_response_trait] trait. This can alternatively be used to
define response attributes. _`response`_ attribute cannot co-exist with other than _`status_code`_ attribute.
define response attributes. _`response`_ attribute cannot co-exist with other than _`status_code`_ attribute.

* `content((...), (...))` Can be used to define multiple return types for single response status code. Supported format for single
_content_ is `(content_type = response_body, example = "...", examples(...))`. _`example`_
Expand Down Expand Up @@ -324,7 +324,7 @@ tuples separated by commas:
E.g. _`Path, Query, Header, Cookie`_

* `deprecated` Define whether the parameter is deprecated or not. Can optionally be defined
with explicit `bool` value as _`deprecated = bool`_.
with explicit `bool` value as _`deprecated = bool`_.

* `description = "..."` Define possible description for the parameter as str.

Expand Down
1 change: 0 additions & 1 deletion crates/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

use std::convert::Infallible;
use std::error::Error as StdError;
use std::future::Future;

use hyper::upgrade::OnUpgrade;
use percent_encoding::{CONTROLS, utf8_percent_encode};
Expand Down
1 change: 0 additions & 1 deletion crates/rate-limiter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use std::borrow::Borrow;
use std::error::Error as StdError;
use std::future::Future;
use std::hash::Hash;

use salvo_core::conn::SocketAddr;
Expand Down
1 change: 0 additions & 1 deletion crates/rate-limiter/src/quota.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::borrow::Borrow;
use std::convert::Infallible;
use std::error::Error as StdError;
use std::future::Future;
use std::hash::Hash;

use serde::{Deserialize, Serialize};
Expand Down
8 changes: 1 addition & 7 deletions crates/serve-static/src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,7 @@ impl Handler for StaticDir {
.unwrap_or_default();
let accept_algos = http::parse_accept_encoding(header)
.into_iter()
.filter_map(|(algo, _level)| {
if let Ok(algo) = algo.parse::<CompressionAlgo>() {
Some(algo)
} else {
None
}
})
.filter_map(|(algo, _level)| algo.parse::<CompressionAlgo>().ok())
.collect::<HashSet<_>>();
for (algo, exts) in &self.compressed_variations {
if accept_algos.contains(algo) {
Expand Down

0 comments on commit b16c67a

Please sign in to comment.