From 359fa2e8aca3e35d909673bdb8677acd8242dcd0 Mon Sep 17 00:00:00 2001 From: gengteng Date: Wed, 27 Sep 2023 19:09:54 +0800 Subject: [PATCH] impl FromRef<()> for ValidationContext<()> --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 795d13c..faa8528 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,7 +182,7 @@ impl ValidationContext<()> { /// /// fn custom_response(errors: ValidationErrors) -> Response { /// // return response with custom status code and body - /// (StatusCode::NOT_FOUND, Json(errors)).into_response() + /// (StatusCode::IM_A_TEAPOT, Json(errors)).into_response() /// } /// /// let context = ValidationContext::custom(custom_response); @@ -293,6 +293,12 @@ impl ValidationContext { } } +impl FromRef<()> for ValidationContext<()> { + fn from_ref(_: &()) -> Self { + ValidationContext::default() + } +} + /// `ValidError` is the error type returned when the `Valid` extractor fails. /// /// It has two variants: