From fc5a0e88215df639a40b0a2c5a3543a866827e8d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 15 Jan 2019 19:25:49 -0800 Subject: [PATCH] allow deserialize from the path --- src/path.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/path.rs b/src/path.rs index bcd4439fe..9fe94f256 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,6 +1,9 @@ use std::ops::Index; use std::rc::Rc; +use serde::de; + +use crate::de::PathDeserializer; use crate::RequestPath; #[derive(Debug, Clone, Copy)] @@ -149,6 +152,11 @@ impl Path { params: self, } } + + /// Try to deserialize matching parameters to a specified type `U` + pub fn load<'de, U: serde::Deserialize<'de>>(&'de self) -> Result { + de::Deserialize::deserialize(PathDeserializer::new(self)) + } } #[derive(Debug)]