From 655eaa85196d7c0e1eada3ee4479344cc99f8091 Mon Sep 17 00:00:00 2001 From: gengteng Date: Sat, 22 Jul 2023 13:36:04 +0800 Subject: [PATCH] fix clippy warning --- README.md | 5 +++++ tests/basic.rs | 8 ++++---- tests/custom.rs | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3436794..94bbd31 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # axum-valid +![LICENSE](https://img.shields.io/badge/license-MIT-blue) +[![dependency status](https://deps.rs/repo/github/gengteng/axum-valid/status.svg)](https://deps.rs/repo/github/gengteng/axum-valid) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/gengteng/axum-valid/.github/workflows/main.yml?branch=main)](https://github.com/gengteng/axum-valid/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/github/gengteng/axum-valid/badge.svg?branch=main)](https://coveralls.io/github/gengteng/axum-valid?branch=main) + This crate provides a `Valid` type that can be used in combination with `Json`, `Path`, `Query`, and `Form` types to validate the entities that implement the `Validate` trait. ## Usage diff --git a/tests/basic.rs b/tests/basic.rs index d941a73..a4b8ca9 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -15,10 +15,10 @@ use std::net::SocketAddr; use validator::Validate; mod route { - pub const PATH: &'static str = "/path/:v0/:v1"; - pub const QUERY: &'static str = "/query"; - pub const FORM: &'static str = "/form"; - pub const JSON: &'static str = "/json"; + pub const PATH: &str = "/path/:v0/:v1"; + pub const QUERY: &str = "/query"; + pub const FORM: &str = "/form"; + pub const JSON: &str = "/json"; } #[tokio::test] diff --git a/tests/custom.rs b/tests/custom.rs index af29f2e..0ee63a1 100644 --- a/tests/custom.rs +++ b/tests/custom.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use std::net::SocketAddr; use validator::Validate; -const MY_DATA_HEADER: &'static str = "My-Data"; +const MY_DATA_HEADER: &str = "My-Data"; // 1. Implement your own extractor. // 1.1. Define you own extractor type. @@ -56,7 +56,7 @@ where return Err(MyDataRejection::Null); }; - serde_json::from_slice(value.as_bytes()).map_err(|e| MyDataRejection::InvalidJson(e)) + serde_json::from_slice(value.as_bytes()).map_err(MyDataRejection::InvalidJson) } } @@ -67,7 +67,7 @@ impl HasValidate for MyData { type Rejection = MyDataRejection; fn get_validate(&self) -> &Self::Validate { - &self + self } }