Skip to content

Commit

Permalink
trait Serialize uses reference to self instead of move.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grinkers committed Feb 14, 2024
1 parent f968e9d commit 656c692
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn expand_named_struct(struct_name: &Ident, fields: &Punctuated<Field, Comma>) -

quote! {
impl edn_rs::Serialize for #struct_name {
fn serialize(self) -> std::string::String {
fn serialize(&self) -> std::string::String {
let mut s = std::string::String::new();
s.push_str("{ ");
#(s.push_str(&#it);)*
Expand All @@ -58,7 +58,7 @@ fn expand_unnamed_struct(struct_name: &Ident, fields: &Punctuated<Field, Comma>)

quote! {
impl edn_rs::Serialize for #struct_name {
fn serialize(self) -> std::string::String {
fn serialize(&self) -> std::string::String {
let mut s = std::string::String::from("{ ");
#(s.push_str(&#it);)*
s.push_str("}");
Expand All @@ -71,7 +71,7 @@ fn expand_unnamed_struct(struct_name: &Ident, fields: &Punctuated<Field, Comma>)
fn expand_unit_struct(struct_name: &Ident) -> TokenStream2 {
quote! {
impl edn_rs::Serialize for #struct_name {
fn serialize(self) -> std::string::String {
fn serialize(&self) -> std::string::String {
String::from("nil")
}
}
Expand All @@ -94,7 +94,7 @@ fn expand_enum(enum_name: &Ident, data_enum: &DataEnum) -> TokenStream2 {

quote! {
impl edn_rs::Serialize for #enum_name {
fn serialize(self) -> std::string::String {
fn serialize(&self) -> std::string::String {
match self {
#(#it)*
}
Expand Down

0 comments on commit 656c692

Please sign in to comment.