From d4721d77b7c11318b3334e0dfa141db1e1466c5a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 27 Nov 2019 10:59:37 +0100 Subject: [PATCH] api-macro: JSONValue to bool shortcut Signed-off-by: Wolfgang Bumiller --- proxmox-api-macro/src/util.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index c49f2333..10a58f71 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -167,6 +167,14 @@ impl TryFrom for syn::LitBool { } } +/// Expect a json value to be a literal boolean: +impl TryFrom for bool { + type Error = syn::Error; + fn try_from(value: JSONValue) -> Result { + Ok(syn::LitBool::try_from(value)?.value) + } +} + /// Expect a json value to be an identifier: impl TryFrom for Ident { type Error = syn::Error;