Skip to content
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

Opt-in automatic collection of expected values on alt #415

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't Ord + core::cmp::Ord redundant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, some oversight when combining the commits into one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Clone and Debug, if this is because LongestMatch impls those traits, wouldn't that be dependent on whether the Ord does so, meaning we don't need these bounds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove them. Clone was required because I initially stored the ord in LongestMatch. I updated LongestMatch to store the actual checkpoint now.


/// 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
Expand Down