Skip to content

Commit

Permalink
fix: Handle newtypes with a public field
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Apr 16, 2019
1 parent 81ebabe commit d1fef96
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion base/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
iter,
marker::PhantomData,
mem,
ops::{self, Deref, DerefMut},
ops::{Deref, DerefMut},
rc::Rc,
sync::Arc,
};
Expand Down
5 changes: 3 additions & 2 deletions codegen/src/getable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ where
// Treat newtype structs as just their inner type
let (first, second) = (fields.next(), fields.next());
match (&first, &second) {
(Some(field_ty), None) => {
(Some(field), None) => {
let field_ty = &field.ty;
return quote! {
#ident (
<#field_ty as _gluon_api::Getable<'__vm, '__value>>::from_value(vm, variants)
)
}
};
}
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/tests/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn normal_struct() {
}

#[derive(Debug, PartialEq, VmType, Pushable, Getable)]
struct Newtype(Struct);
struct Newtype(pub Struct);

fn load_newtype_mod(vm: &Thread) -> vm::Result<ExternModule> {
let module = record! {
Expand Down

0 comments on commit d1fef96

Please sign in to comment.