Skip to content

Commit

Permalink
Merge pull request #41 from Grinkers/fix-serialize+circulardep
Browse files Browse the repository at this point in the history
Fix serialize+circulardep
  • Loading branch information
evaporei committed Feb 14, 2024
2 parents 4f87d7c + 5d93cb6 commit f968e9d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ path = "tests/progress.rs"
syn = "1.0"
quote = "1.0"
proc-macro2 = "1.0"
edn-rs = "0.16.6"
edn-rs = { git = "https://github.com/edn-rs/edn-rs.git" } # TODO lock in version once stable

[dev-dependencies]
trybuild = { version = "1.0", features = ["diff"] }
Expand Down
6 changes: 1 addition & 5 deletions src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,10 @@ fn expand_unnamed_struct(struct_name: &Ident, fields: &Punctuated<Field, Comma>)
}
});

let str_struct_name = edn::camel_to_kebab(&quote! {#struct_name}.to_string());

quote! {
impl edn_rs::Serialize for #struct_name {
fn serialize(self) -> std::string::String {
let mut s = std::string::String::from(':');
s.push_str(#str_struct_name);
s.push_str("{ ");
let mut s = std::string::String::from("{ ");
#(s.push_str(&#it);)*
s.push_str("}");
s
Expand Down
2 changes: 1 addition & 1 deletion tests/unnamed_struct_deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum Kind {
pub struct Person(String, usize, Kind);

fn main() -> Result<(), EdnError> {
let edn_person = ":person{ 0 \"joana\", 1 290000, 2 :kind/pirate, }";
let edn_person = "{ 0 \"joana\", 1 290000, 2 :kind/pirate, }";

let person: Person = edn_rs::from_str(edn_person)?;

Expand Down
2 changes: 1 addition & 1 deletion tests/unnamed_struct_serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {

assert_eq!(
edn_rs::to_string(person),
":person{ 0 \"joana\", 1 290000, 2 :kind/chill, }"
"{ 0 \"joana\", 1 290000, 2 :kind/chill, }"
);
}

0 comments on commit f968e9d

Please sign in to comment.