-
Notifications
You must be signed in to change notification settings - Fork 24
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
Use std::ops::Range instead of reimplementing the functionality #23
Comments
To make it easy to use, the crate defined range should define |
If we use |
Why is the |
The |
The sample code: #[derive(Clone, Debug)]
pub struct RangeInclusive {
inner: std::ops::RangeInclusive<u64>
}
impl PartialEq for RangeInclusive {
fn eq(&self, other: &Self) -> bool {
}
}
impl Eq for RangeInclusive {}
impl PartialOrd for RangeInclusive {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
}
}
impl Ord for RangeInclusive {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
}
}
impl RangeInclusive {
pub fn new(start: u64, end: u64) -> Result<Self> {
}
pub fn contains(&self, other: &RangeInclusive) -> bool {
}
pub fn overlaps(&self, other: &RangeInclusive) -> bool {
}
}
|
The
Range
object already exists in Rust. Instead of reimplementing the functionality, we can just extend such that we can add the needed functionality, which for now is just theoverlaps
function.Also, depending on how the crate is shaped, we will need to use either
Range
orRangeInclusive
, where the latter represents a range that is inclusive on both ends:The text was updated successfully, but these errors were encountered: