Skip to content

Commit

Permalink
fix(gadget-blueprint-proc-macro)!: recognize ByteBuf as `FieldType:…
Browse files Browse the repository at this point in the history
…:Bytes`
  • Loading branch information
Serial-ATA committed Nov 26, 2024
1 parent 2e6f61d commit c8b0158
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions macros/blueprint-proc-macro/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ pub fn path_to_field_type(path: &syn::Path) -> syn::Result<FieldType> {
.last()
.ok_or_else(|| syn::Error::new_spanned(path, "path must have at least one segment"))?;
let ident = &seg.ident;
if ident == "ByteBuf" {
return Ok(FieldType::Bytes);
}

let args = &seg.arguments;
match args {
syn::PathArguments::None => {
Expand All @@ -104,10 +108,7 @@ pub fn path_to_field_type(path: &syn::Path) -> syn::Result<FieldType> {
let inner_arg = &inner.args[0];
if let syn::GenericArgument::Type(inner_ty) = inner_arg {
let inner_type = type_to_field_type(inner_ty)?;
match inner_type.ty {
FieldType::Uint8 => Ok(FieldType::Bytes),
others => Ok(FieldType::List(Box::new(others))),
}
Ok(FieldType::List(Box::new(inner_type.ty)))
} else {
Err(syn::Error::new_spanned(
inner_arg,
Expand Down

0 comments on commit c8b0158

Please sign in to comment.