Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Nov 11, 2024
1 parent 07f7de8 commit bcf2842
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 18 deletions.
1 change: 0 additions & 1 deletion crates/core/src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl Display for Holding {
}

/// `Listener` represents a listener that can bind to a specific address and port and return an acceptor.

pub trait Listener {
/// Acceptor type.
type Acceptor: Acceptor;
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/conn/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl HttpBuilder {

#[allow(dead_code)]
#[allow(clippy::future_not_send)]
pub(crate) async fn read_version<'a, A>(mut reader: A) -> IoResult<(Version, Rewind<A>)>
pub(crate) async fn read_version<A>(mut reader: A) -> IoResult<(Version, Rewind<A>)>
where
A: AsyncRead + Unpin,
{
Expand Down Expand Up @@ -288,7 +288,7 @@ where
if this.buf.filled() == H2_PREFACE {
*this.version = Version::HTTP_2;
}
return Poll::Ready(Ok((*this.version, this.buf.filled().to_vec())));
Poll::Ready(Ok((*this.version, this.buf.filled().to_vec())))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub trait HttpConnection {
fn fusewire(&self) -> Option<ArcFusewire>;
}

/// Get Http version from alph.
// /// Get Http version from alph.
// pub fn version_from_alpn(proto: impl AsRef<[u8]>) -> Version {
// if proto.as_ref().windows(2).any(|window| window == b"h2") {
// Version::HTTP_2
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/routing/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl CombWisp {
let mut is_greedy = false;
let mut wild_start = None;
let mut wild_regex = None;
let any_chars_regex = Regex::new(".*").expect("regex should worked");
for wisp in wisps {
match wisp {
WispKind::Const(wisp) => {
Expand Down Expand Up @@ -342,7 +343,7 @@ impl CombWisp {
if wisp.0.starts_with('*') {
is_greedy = true;
let (star_mark, name) = crate::routing::split_wild_name(&wisp.0);
wild_regex = Some(Regex::new(".*").expect("regex should worked"));
wild_regex = Some(any_chars_regex.clone());
wild_start = Some(star_mark.to_owned());
names.push(name.to_owned());
} else {
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ impl<A: Acceptor + Send> Server<A> {
///
/// ```no_run
/// use salvo_core::prelude::*;

/// #[handler]
/// async fn hello() -> &'static str {
/// "Hello World"
Expand Down
4 changes: 2 additions & 2 deletions crates/oapi-macros/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) struct ComponentSchema {
tokens: TokenStream,
}

impl<'c> ComponentSchema {
impl ComponentSchema {
pub(crate) fn new(
ComponentSchemaProps {
type_tree,
Expand Down Expand Up @@ -519,7 +519,7 @@ impl<'c> ComponentSchema {
Ok(())
}

pub(crate) fn get_deprecated(deprecated: Option<&'c Deprecated>) -> Option<TokenStream> {
pub(crate) fn get_deprecated(deprecated: Option<&Deprecated>) -> Option<TokenStream> {
deprecated.map(|deprecated| quote! { .deprecated(#deprecated) })
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oapi-macros/src/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ enum Description<'a> {
LitStrOrExpr(&'a LitStrOrExpr),
Vec(&'a [String]),
}
impl<'a> Description<'a> {
impl Description<'_> {
fn is_empty(&self) -> bool {
match self {
Self::LitStrOrExpr(value) => value.is_empty(),
Expand Down Expand Up @@ -250,7 +250,7 @@ enum Summary<'a> {
LitStrOrExpr(&'a LitStrOrExpr),
Str(&'a str),
}
impl<'a> Summary<'a> {
impl Summary<'_> {
pub(crate) fn is_empty(&self) -> bool {
match self {
Self::LitStrOrExpr(value) => value.is_empty(),
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 @@ -370,7 +370,7 @@ struct ToResponseNamedStructResponse<'p>(ResponseTuple<'p>);

impl Response for ToResponseNamedStructResponse<'_> {}

impl<'p> ToResponseNamedStructResponse<'p> {
impl ToResponseNamedStructResponse<'_> {
fn new(
attributes: &[Attribute],
ident: &Ident,
Expand Down
4 changes: 2 additions & 2 deletions crates/oapi-macros/src/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ pub(crate) struct DeriveResponsesAttributes<T> {
description: parse_utils::LitStrOrExpr,
}

impl<'r> From<DeriveResponsesAttributes<DeriveToResponsesValue>> for ResponseValue<'r> {
impl From<DeriveResponsesAttributes<DeriveToResponsesValue>> for ResponseValue<'_> {
fn from(value: DeriveResponsesAttributes<DeriveToResponsesValue>) -> Self {
Self::from_derive_to_responses_value(value.derive_value, value.description)
}
}

impl<'r> From<DeriveResponsesAttributes<Option<DeriveToResponseValue>>> for ResponseValue<'r> {
impl From<DeriveResponsesAttributes<Option<DeriveToResponseValue>>> for ResponseValue<'_> {
fn from(
DeriveResponsesAttributes::<Option<DeriveToResponseValue>> {
derive_value,
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi-macros/src/schema/enum_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl<'c, T: ToTokens> CustomEnum<'c, T> {
}
}

impl<'c, T> ToTokens for CustomEnum<'c, T>
impl< T> ToTokens for CustomEnum<'_, T>
where
T: ToTokens,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi-macros/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ where
}
}

impl<'a, T> Deref for Array<'a, T>
impl<T> Deref for Array<'_, T>
where
T: Sized + ToTokens,
{
Expand Down
1 change: 1 addition & 0 deletions crates/oapi-macros/tests/derive_to_schema_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
use assert_json_diff::assert_json_eq;
use salvo::oapi::extract::*;
use salvo::prelude::*;
Expand Down
1 change: 1 addition & 0 deletions crates/oapi-macros/tests/endpoint_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(missing_docs)]
use assert_json_diff::assert_json_eq;
use salvo::oapi::extract::*;
use salvo::prelude::*;
Expand Down
6 changes: 3 additions & 3 deletions crates/oapi/src/openapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<'de> Deserialize<'de> for OpenApiVersion {
{
struct VersionVisitor;

impl<'v> Visitor<'v> for VersionVisitor {
impl Visitor<'_> for VersionVisitor {
type Value = OpenApiVersion;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
Expand Down Expand Up @@ -636,7 +636,7 @@ impl<'de> Deserialize<'de> for Deprecated {
D: serde::Deserializer<'de>,
{
struct BoolVisitor;
impl<'de> Visitor<'de> for BoolVisitor {
impl Visitor<'_> for BoolVisitor {
type Value = Deprecated;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down Expand Up @@ -696,7 +696,7 @@ impl<'de> Deserialize<'de> for Required {
D: serde::Deserializer<'de>,
{
struct BoolVisitor;
impl<'de> Visitor<'de> for BoolVisitor {
impl Visitor<'_> for BoolVisitor {
type Value = Required;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down

0 comments on commit bcf2842

Please sign in to comment.