From b4a7b4d8108672091647d0948b891554fa4fa680 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 8 Feb 2020 13:44:46 +0100 Subject: [PATCH] add convenient methods for AuthResult --- gotham_restful/src/result.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gotham_restful/src/result.rs b/gotham_restful/src/result.rs index ef258a4..22c819e 100644 --- a/gotham_restful/src/result.rs +++ b/gotham_restful/src/result.rs @@ -251,6 +251,25 @@ pub enum AuthResult AuthErr } +impl AuthResult +{ + pub fn is_ok(&self) -> bool + { + match self { + Self::Ok(_) => true, + _ => false + } + } + + pub fn unwrap(self) -> T + { + match self { + Self::Ok(data) => data, + _ => panic!() + } + } +} + impl From for AuthResult { fn from(t : T) -> Self