Skip to content

Commit

Permalink
Merge pull request #458 from SeokminHong/fix-impl-encoder
Browse files Browse the repository at this point in the history
Fix moving out terms
  • Loading branch information
evnu committed Jun 2, 2022
2 parents a880bb3 + 77ade5b commit 990249c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rustler_codegen/src/ex_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn gen_decoder(ctx: &Context, fields: &[&Field], atoms_module_name: &Ident) -> T
T: rustler::Decoder<'a>,
{
use rustler::Encoder;
match ::rustler::Decoder::decode(term.map_get(field)?) {
match ::rustler::Decoder::decode(term.map_get(&field)?) {
Err(_) => Err(::rustler::Error::RaiseTerm(Box::new(format!(
"Could not decode field :{:?} on %{}{{}}",
field, #struct_name_str
Expand Down
4 changes: 2 additions & 2 deletions rustler_codegen/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn gen_decoder(ctx: &Context, fields: &[&Field], atoms_module_name: &Ident) -> T
T: rustler::Decoder<'a>,
{
use rustler::Encoder;
match ::rustler::Decoder::decode(term.map_get(field)?) {
match ::rustler::Decoder::decode(term.map_get(&field)?) {
Err(_) => Err(::rustler::Error::RaiseTerm(Box::new(format!(
"Could not decode field :{:?} on %{{}}",
field
Expand Down Expand Up @@ -118,7 +118,7 @@ fn gen_encoder(ctx: &Context, fields: &[&Field], atoms_module_name: &Ident) -> T
let atom_fun = Context::field_to_atom_fun(field);

quote_spanned! { field.span() =>
map = map.map_put(#atom_fun(), self.#field_ident).unwrap();
map = map.map_put(#atom_fun(), &self.#field_ident).unwrap();
}
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion rustler_codegen/src/tagged_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn gen_decoder(ctx: &Context, variants: &[&Variant], atoms_module_name: &Ident)
T: ::rustler::Decoder<'a>,
{
use ::rustler::Encoder;
match ::rustler::Decoder::decode(term.map_get(field)?) {
match ::rustler::Decoder::decode(term.map_get(&field)?) {
Err(_) => Err(::rustler::Error::RaiseTerm(Box::new(format!(
"Could not decode field :{:?} on %{{}}",
field
Expand Down

0 comments on commit 990249c

Please sign in to comment.