-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes ordered_elements implementation #225
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! My comments are mostly comment clarifications.
// Need to clone the range because strangely &RangeInclusive doesn't | ||
// implement Copy or IntoIterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happily, this weirdness is getting addressed in edition 2024.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to consider RE: indentation before you merge.
ion-schema/src/violation.rs
Outdated
let one_indent = " "; | ||
// TODO: Consider extracting this into a static or thread local variable. | ||
let mut indentation = vec![one_indent.to_string()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but why have a Vec
of indentation String
s instead of a single String
that you add spacing to as the stack gets deeper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, it's because I've been using too much Java recently, and I forgot that strings can be mutated in Rust. I'll fix it.
Issue #, if available:
Fix #56
Fix #221
Fix #105
Description of changes:
Complete rewrite of the state machine for ordered elements. This fixes all the correctness issues with
ordered_elements
; now all of theion-schema-tests
cases forordered_elements
are enabled and passing. It also brings improved violation messaging for theordered_elements
constraint—although not quite as nice as amazon-ion/ion-schema-kotlin#228 because the source ISL isn't available by the time we're constructing the ordered elements NFA, and I didn't want to tackle that as part of this PR since I think the violations may end up being refactored before v1.0.0 anyway.That being said, I did go and update the implementation of
Display
forViolation
because it was printing stuff on one line in a completely unusable way. The new implementation is a little bit more likeion-schema-kotlin
in that it prints a multi-line tree of violations.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.