Skip to content

Commit dda9d45

Browse files
committed
Support Unit struct types
1 parent 4f282d4 commit dda9d45

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

c-bindings-gen/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
805805
define_field!(('a' as u8 + idx as u8) as char, ('0' as u8 + idx as u8) as char, field);
806806
}
807807
}
808-
_ => unimplemented!()
808+
syn::Fields::Unit => {},
809809
}
810810

811811
if all_fields_settable {
@@ -828,7 +828,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
828828
types.write_c_type(w, &field.ty, Some(&gen_types), false);
829829
}
830830
}
831-
_ => unreachable!()
831+
syn::Fields::Unit => {},
832832
}
833833
write!(w, ") -> {} {{\n\t", struct_name).unwrap();
834834
match &s.fields {
@@ -848,7 +848,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
848848
}
849849
}
850850
},
851-
_ => unreachable!()
851+
syn::Fields::Unit => {},
852852
}
853853
write!(w, "{} {{ inner: ObjOps::heap_alloc(", struct_name).unwrap();
854854
match &s.fields {
@@ -876,7 +876,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
876876
}
877877
write!(w, "\t)").unwrap();
878878
},
879-
_ => unreachable!()
879+
syn::Fields::Unit => write!(w, "{}::{} {{}}", types.module_path, struct_name).unwrap(),
880880
}
881881
writeln!(w, "), is_owned: true }}\n}}").unwrap();
882882
}

0 commit comments

Comments
 (0)