From c8af836f868abbaf0562d4e62eda901047566577 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Thu, 14 Sep 2023 00:50:56 +0100 Subject: [PATCH] lexgen: Support NonZero --- lexgen/src/compiller/field.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lexgen/src/compiller/field.rs b/lexgen/src/compiller/field.rs index fd5061a..d8511f9 100644 --- a/lexgen/src/compiller/field.rs +++ b/lexgen/src/compiller/field.rs @@ -123,6 +123,7 @@ pub(super) enum FieldType { // U32, I64, U64, + NonZeroU64, Blob, Any, Bool, @@ -195,11 +196,15 @@ impl FieldType { None => FieldType::U64, _ => todo!(), }, + Some(1) => match i.maximum { + None => FieldType::NonZeroU64, + _ => todo!(), + }, None => match i.maximum { None => FieldType::I64, _ => todo!(), }, - _ => todo!(), + _ => todo!("{i:?}"), }; (this, &i.description) @@ -271,6 +276,7 @@ impl ToTokens for FieldType { FieldType::Bool => quote!(bool).to_tokens(tokens), FieldType::U64 => quote!(u64).to_tokens(tokens), FieldType::I64 => quote!(i64).to_tokens(tokens), + FieldType::NonZeroU64 => quote!(::std::num::NonZeroU64).to_tokens(tokens), FieldType::Vec(inner) => { let inner = inner.to_token_stream();