From e40bb3465d8e0b24d7c9df0c06269fad7dc887de Mon Sep 17 00:00:00 2001 From: frectonz Date: Fri, 15 Nov 2024 16:48:39 +0300 Subject: [PATCH] fix: prefix extraction for empty string --- parenv-derive/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parenv-derive/src/lib.rs b/parenv-derive/src/lib.rs index ab5de2f..a0630a4 100644 --- a/parenv-derive/src/lib.rs +++ b/parenv-derive/src/lib.rs @@ -37,10 +37,13 @@ pub fn derive_environment(input: TokenStream) -> TokenStream { _ => None, })?; - Some(prefix) + Some(if prefix.is_empty() { + prefix + } else { + prefix[1..(prefix.len() - 1)].to_owned() + }) }) .unwrap_or_default(); - let prefix = &prefix[1..(prefix.len() - 1)]; let field_descs: Vec<_> = fields .named