bdarcus / csln

Reimagining CSL
Mozilla Public License 2.0
13 stars 0 forks source link

Figure out Rust options, unwrap, etc #27

Closed bdarcus closed 1 year ago

bdarcus commented 1 year ago

Some of the code here is just kind of ugly, mostly because I'm still a newbie with Rust.

In particular, there's a lot of unwrap and such, since I'm defining a lot of the key struct fields as optional.

If I change that, hoping to rely on derive default, schemars will requires the fields in the JSON, and I can't figure out how to avoid that.

EDIT: in Hayagriva, the typst folks have the FmtOptionExt<'a> trait, which they implement in such a way they can do stuff like this:

database.citation(&mut formatter, &citations).display.value
bdarcus commented 1 year ago

In #94, I mostly figured this out.