From 969d10a9449f7deecc1e5c2d89e043872dbb9a06 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 27 Dec 2021 13:18:52 -0800 Subject: [PATCH] docs: fix Reject example compiler failure --- src/reject.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/reject.rs b/src/reject.rs index b4edb869b..fd0918841 100644 --- a/src/reject.rs +++ b/src/reject.rs @@ -28,7 +28,7 @@ //! #[derive(Debug)] //! struct InvalidParameter; //! -//! impl reject::Reject for InvalidParameter {}; +//! impl reject::Reject for InvalidParameter {} //! //! // Custom rejection handler that maps rejections into responses. //! async fn handle_rejection(err: Rejection) -> Result { @@ -42,23 +42,18 @@ //! } //! } //! -//! #[tokio::main] -//! async fn main() { //! -//! // Filter on `/:id`, but reject with InvalidParameter if the `id` is `0`. -//! // Recover from this rejection using a custom rejection handler. -//! let route = warp::path::param() -//! .and_then(|id: u32| async move { -//! if id == 0 { -//! Err(warp::reject::custom(InvalidParameter)) -//! } else { -//! Ok("id is valid") -//! } -//! }) -//! .recover(handle_rejection); -//! -//! warp::serve(route).run(([127, 0, 0, 1], 3030)).await; -//! } +//! // Filter on `/:id`, but reject with InvalidParameter if the `id` is `0`. +//! // Recover from this rejection using a custom rejection handler. +//! let route = warp::path::param() +//! .and_then(|id: u32| async move { +//! if id == 0 { +//! Err(warp::reject::custom(InvalidParameter)) +//! } else { +//! Ok("id is valid") +//! } +//! }) +//! .recover(handle_rejection); //! ``` use std::any::Any;