rust-italia / dgc

A parser and validator for the EU Digital Green Certificate (dgc) a.k.a. greenpass
https://github.com/rust-italia/dgc
MIT License
26 stars 11 forks source link

Uniformity in the use of Cow instead of String #32

Closed nappa85 closed 2 years ago

nappa85 commented 2 years ago

Cow is used in all deserializable structs instead of String to gain uniformity lookup_value takes a mutable reference and replaces in place instead of returning the new value Test code simplified using Into instead of From for better readability

lu-zero commented 2 years ago

beside the typo in the doctest ^^

allevo commented 2 years ago

Why the code force to have 'static lifetime? Is it really needed?

nappa85 commented 2 years ago

Why the code force to have 'static lifetime? Is it really needed?

Because this way we don't have explicit lifetimes in all structs, serde deserializes in an owned String anyway and lookup_value already uses static strings. Using a named lifetime seems like an overcomplication to me