Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix some clippy #925

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poem-grpc/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct GetBinaryAll<'a> {
iter: poem::http::header::ValueIter<'a, HeaderValue>,
}

impl<'a> Iterator for GetBinaryAll<'a> {
impl Iterator for GetBinaryAll<'_> {
type Item = Vec<u8>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/base64_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<T: Send> Payload for Base64<T> {
&& (content_type.subtype() == "plain"
|| content_type
.suffix()
.map_or(false, |v| v == "plain")))
.is_some_and(|v| v == "plain")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<T: Send> Payload for Binary<T> {
&& (content_type.subtype() == "octet-stream"
|| content_type
.suffix()
.map_or(false, |v| v == "octet-stream")))
.is_some_and(|v| v == "octet-stream")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<T: Type> Payload for Form<T> {
&& (content_type.subtype() == "x-www-form-urlencoded"
|| content_type
.suffix()
.map_or(false, |v| v == "x-www-form-urlencoded")))
.is_some_and(|v| v == "x-www-form-urlencoded")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<T: Send> Payload for Html<T> {
&& (content_type.subtype() == "html"
|| content_type
.suffix()
.map_or(false, |v| v == "html")))
.is_some_and(|v| v == "html")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: Type> Payload for Json<T> {
&& (content_type.subtype() == "json"
|| content_type
.suffix()
.map_or(false, |v| v == "json")))
.is_some_and(|v| v == "json")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/plain_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<T: Send> Payload for PlainText<T> {
&& (content_type.subtype() == "plain"
|| content_type
.suffix()
.map_or(false, |v| v == "plain")))
.is_some_and(|v| v == "plain")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: Type> Payload for Xml<T> {
&& (content_type.subtype() == "xml"
|| content_type
.suffix()
.map_or(false, |v| v == "xml")))
.is_some_and(|v| v == "xml")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
2 changes: 1 addition & 1 deletion poem-openapi/src/payload/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T: Type> Payload for Yaml<T> {
&& (content_type.subtype() == "yaml"
|| content_type
.suffix()
.map_or(false, |v| v == "yaml")))
.is_some_and(|v| v == "yaml")))
}

fn schema_ref() -> MetaSchemaRef {
Expand Down
6 changes: 3 additions & 3 deletions poem-openapi/src/registry/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Serialize for MetaSchemaRef {

struct PathMap<'a>(&'a [MetaApi], Option<&'a str>);

impl<'a> Serialize for PathMap<'a> {
impl Serialize for PathMap<'_> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut s = serializer.serialize_map(Some(self.0.len()))?;
for api in self.0 {
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Serialize for MetaResponses {

struct WebhookMap<'a>(&'a [MetaWebhook]);

impl<'a> Serialize for WebhookMap<'a> {
impl Serialize for WebhookMap<'_> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut s = serializer.serialize_map(Some(self.0.len()))?;
for webhook in self.0 {
Expand All @@ -86,7 +86,7 @@ pub(crate) struct Document<'a> {
pub(crate) url_prefix: Option<&'a str>,
}

impl<'a> Serialize for Document<'a> {
impl Serialize for Document<'_> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
4 changes: 2 additions & 2 deletions poem-openapi/src/types/external/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl ToHeader for String {
}
}

impl<'a> Type for &'a str {
impl Type for &str {
const IS_REQUIRED: bool = true;

type RawValueType = Self;
Expand All @@ -109,7 +109,7 @@ impl<'a> Type for &'a str {
}
}

impl<'a> ToJSON for &'a str {
impl ToJSON for &str {
fn to_json(&self) -> Option<Value> {
Some(Value::String(self.to_string()))
}
Expand Down
2 changes: 1 addition & 1 deletion poem/src/endpoint/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
}
}

/// The enum `EitherEndpoint` with variants `Left`` and `Right` is a general
/// The enum `EitherEndpoint` with variants `Left` and `Right` is a general
/// purpose sum type with two cases.
pub enum EitherEndpoint<A, B> {
/// A endpoint of type `A`
Expand Down
3 changes: 1 addition & 2 deletions poem/src/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ where
}
}

/// The enum `EitherMiddleware` with variants `Left`` and `Right` is a general
/// The enum `EitherMiddleware` with variants `Left` and `Right` is a general
/// purpose sum type with two cases.

pub enum EitherMiddleware<A, B, E> {
/// A middleware of type `A`
A(A, PhantomData<E>),
Expand Down
4 changes: 2 additions & 2 deletions poem/src/web/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ pub struct PrivateCookieJar<'a> {
cookie_jar: &'a CookieJar,
}

impl<'a> PrivateCookieJar<'a> {
impl PrivateCookieJar<'_> {
/// Adds cookie to the parent jar. The cookie’s value is encrypted with
/// authenticated encryption assuring confidentiality, integrity, and
/// authenticity.
Expand Down Expand Up @@ -608,7 +608,7 @@ pub struct SignedCookieJar<'a> {
cookie_jar: &'a CookieJar,
}

impl<'a> SignedCookieJar<'a> {
impl SignedCookieJar<'_> {
/// Adds cookie to the parent jar. The cookie’s value is signed assuring
/// integrity and authenticity.
pub fn add(&self, cookie: Cookie) {
Expand Down
2 changes: 1 addition & 1 deletion poem/src/web/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn is_form_content_type(content_type: &str) -> bool {
&& (content_type.subtype() == "x-www-form-urlencoded"
|| content_type
.suffix()
.map_or(false, |v| v == "x-www-form-urlencoded")))
.is_some_and(|v| v == "x-www-form-urlencoded")))
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion poem/src/web/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn is_json_content_type(content_type: &str) -> bool {
&& (content_type.subtype() == "json"
|| content_type
.suffix()
.map_or(false, |v| v == "json")))
.is_some_and(|v| v == "json")))
}

impl<T: Serialize + Send> IntoResponse for Json<T> {
Expand Down
2 changes: 1 addition & 1 deletion poem/src/web/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn is_xml_content_type(content_type: &str) -> bool {
&& (content_type.subtype() == "xml"
|| content_type
.suffix()
.map_or(false, |v| v == "xml")))
.is_some_and(|v| v == "xml")))
}

impl<T: Serialize + Send> IntoResponse for Xml<T> {
Expand Down
2 changes: 1 addition & 1 deletion poem/src/web/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn is_yaml_content_type(content_type: &str) -> bool {
&& (content_type.subtype() == "yaml"
|| content_type
.suffix()
.map_or(false, |v| v == "yaml")))
.is_some_and(|v| v == "yaml")))
}

impl<T: Serialize + Send> IntoResponse for Yaml<T> {
Expand Down
Loading