serialize everything

This commit is contained in:
Breval Ferrari 2024-10-31 00:24:37 -04:00
parent 829cb64511
commit a82579dfa5
No known key found for this signature in database
GPG key ID: 6FED68D87C479A59

View file

@ -46,13 +46,13 @@ impl<'de> Deserialize<'de> for Atoms {
Sheet, Sheet,
} }
#[derive(Deserialize, new)] #[derive(Deserialize, new)]
struct NotesSheet<'a> { struct NotesSheet {
notes: &'a str, notes: String,
sheet: &'a str, sheet: String,
} }
struct NotesSheetVisitor; struct NotesSheetVisitor;
impl<'de> Visitor<'de> for NotesSheetVisitor { impl<'de> Visitor<'de> for NotesSheetVisitor {
type Value = NotesSheet<'de>; type Value = NotesSheet;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("a \"notes\" field and a \"sheet\" field") formatter.write_str("a \"notes\" field and a \"sheet\" field")
} }
@ -98,7 +98,7 @@ impl<'de> Deserialize<'de> for Atoms {
const FIELDS: &[&str] = &["notes", "sheet"]; const FIELDS: &[&str] = &["notes", "sheet"];
let NotesSheet { notes, sheet } = let NotesSheet { notes, sheet } =
deserializer.deserialize_struct("NotesSheet", FIELDS, NotesSheetVisitor)?; deserializer.deserialize_struct("NotesSheet", FIELDS, NotesSheetVisitor)?;
many0(flat_atom_parser(notes))(sheet) let x = many0(flat_atom_parser(&notes))(&sheet)
.map_err(|e| e.to_string()) .map_err(|e| e.to_string())
.map_err(AtomsSerializeError::Parsing) .map_err(AtomsSerializeError::Parsing)
.map_err(de::Error::custom) .map_err(de::Error::custom)
@ -107,7 +107,8 @@ impl<'de> Deserialize<'de> for Atoms {
.map_err(AtomsSerializeError::from) .map_err(AtomsSerializeError::from)
.map_err(de::Error::custom) .map_err(de::Error::custom)
}) })
.map(Atoms) .map(Atoms);
x
} }
} }