From 76fddae3462bd1792d0849813b99051aea072ff7 Mon Sep 17 00:00:00 2001 From: Alexander Polakov Date: Tue, 8 Aug 2023 15:36:33 +0400 Subject: [PATCH] feat: get params as str (#1173) --- types/src/params.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/src/params.rs b/types/src/params.rs index 668c23c7ee..387d652fda 100644 --- a/types/src/params.rs +++ b/types/src/params.rs @@ -150,6 +150,14 @@ impl<'a> Params<'a> { None => 0, } } + + /// Return the underlying JSON string as a `&str`. + pub fn as_str(&self) -> Option<&str> { + match self.0 { + Some(ref cow) => Some(cow.as_ref()), + None => None, + } + } } /// An `Iterator`-like parser for a sequence of [`Params`].