-
Notifications
You must be signed in to change notification settings - Fork 80
Opt-in automatic collection of expected values on alt
#415
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1466,6 +1466,31 @@ where | |
| } | ||
| } | ||
|
|
||
| /// Used to compare checkpoints | ||
| pub trait AsOrd { | ||
| /// The type used to compare checkpoint positions | ||
| type Ord: Ord + Clone + core::cmp::Ord + crate::lib::std::fmt::Debug; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, some oversight when combining the commits into one.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove them. |
||
|
|
||
| /// Get comparable value | ||
| fn as_ord(&self) -> Self::Ord; | ||
| } | ||
|
|
||
| impl<'a, T> AsOrd for &'a [T] { | ||
| type Ord = *const T; | ||
|
|
||
| fn as_ord(&self) -> Self::Ord { | ||
| self.as_ptr() | ||
| } | ||
| } | ||
|
|
||
| impl<'a> AsOrd for &'a str { | ||
| type Ord = *const u8; | ||
|
|
||
| fn as_ord(&self) -> Self::Ord { | ||
| self.as_ptr() | ||
| } | ||
| } | ||
|
|
||
| /// Helper trait for types that can be viewed as a byte slice | ||
| pub trait AsBytes { | ||
| /// Casts the input type to a byte slice | ||
|
|
@@ -2200,6 +2225,22 @@ where | |
| #[derive(Copy, Clone, Debug)] | ||
| pub struct Checkpoint<T>(T); | ||
|
|
||
| impl<T: PartialEq> PartialEq for Checkpoint<T> { | ||
| fn eq(&self, other: &Self) -> bool { | ||
| self.0.eq(&other.0) | ||
| } | ||
| } | ||
|
|
||
| impl<T: Eq> Eq for Checkpoint<T> {} | ||
|
Comment on lines
+2228
to
+2234
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need these?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are currently used by the tests. We can update the tests to compare the |
||
|
|
||
| impl<T: AsOrd> AsOrd for Checkpoint<T> { | ||
| type Ord = T::Ord; | ||
|
|
||
| fn as_ord(&self) -> Self::Ord { | ||
| self.0.as_ord() | ||
| } | ||
| } | ||
|
|
||
| /// A range bounded inclusively for counting parses performed | ||
| #[derive(PartialEq, Eq)] | ||
| pub struct Range { | ||
|
|
||
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.
I feel like this could lead to confusing ordering.
Should we instead check if one is empty and instead pick the other?
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.
I didn't really care about order if there are multiple parsers with the same longest match, but I see how this might be confusing to developers or mess eventually mess with tests when they change parsers..
👍