Closed zbraniecki closed 3 years ago
This patchset also quite significantly simplifies the serde interactions. I simplified the AST a bit to make it easier to interoperate with the reference AST, and pulled serde derive into the AST itself, minus the CommentDef
which is a small hack to handle single-string comments in reference AST.
@stasm @Manishearth could you take a look at this? There aren't many significant changes, so mostly am curious about your take on the AST changes and the Slice
.
I commented out a single reference test - clrf, because I need a bit more work to do to handle comparing a Pattern with multiple TextElement
elements vs one with merged, because the parser produces vec![TextElement("Foo"), TextElement("\n"), TextElement("second line")]
while the reference JSON is vec![TextElement("Foo\n"), TextElement("second line")]
.
I'd like to add custom PartialEq
between two Patterns
which would concatenate all consequitive TextElement
elements before comparing, but Rust doesn't support specialization yet, so I can't easily put PartialEq<ast::Pattern<S: Slice>>
and have ast:Pattern
derive default PartialEq
for generic S.
So I comment it out for now, but plan to revisit later, and verified that everything else matches.
You can read more about 0.13 plans in https://github.com/projectfluent/fluent-rs/issues/193
I like this! I haven't looked closely at all the changes but it seems pretty straightforward.
This patchset is intended for merging.
It refactors the AST to be generic over
Slice
which initially is justString
or&str
.The resolver, for now, is just operating over
&str
one, but in theory we could make itBorrow<ast::Resource<&str>> for ast::Resource<String>
.Performance
Performance looks good:
fluent-syntax
fluent-bundle
Not much impact here, as expected. We'll get more out of further refactors: