pub struct InclusiveRange(pub u64, pub u64);Expand description
An inclusive range which can not have a length of 0.
A replacement for RangeInclusive with some sugar.
§Examples
let range1: InclusiveRange = (10..=20).into();
let range2 = InclusiveRange(10, 20);
assert_eq!(range1, range2);Tuple Fields§
§0: u64§1: u64Implementations§
Source§impl InclusiveRange
impl InclusiveRange
Sourcepub fn start(&self) -> u64
pub fn start(&self) -> u64
Returns the index of the first item within the range
use condow_core::InclusiveRange;
let range: InclusiveRange = (4..=9).into();
assert_eq!(range.start(), 4);Sourcepub fn end_incl(&self) -> u64
pub fn end_incl(&self) -> u64
Returns the index of the last item within the range
use condow_core::InclusiveRange;
let range: InclusiveRange = (4..=9).into();
assert_eq!(range.end_incl(), 9);pub fn validate(&self) -> Result<(), CondowError>
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
Returns the length of the range
use condow_core::InclusiveRange;
let range: InclusiveRange = (4..=9).into();
assert_eq!(range.len(), 6);pub fn to_std_range(self) -> RangeInclusive<u64>
pub fn to_std_range_excl(self) -> Range<u64>
pub fn advance(&mut self, by: u64)
Sourcepub fn http_bytes_range_value(&self) -> String
pub fn http_bytes_range_value(&self) -> String
Returns a value for an HTTP-Range header with bytes as the unit
use condow_core::InclusiveRange;
let range: InclusiveRange = (4..=9).into();
assert_eq!(range.http_bytes_range_value(), "bytes=4-9");Trait Implementations§
Source§impl Clone for InclusiveRange
impl Clone for InclusiveRange
Source§fn clone(&self) -> InclusiveRange
fn clone(&self) -> InclusiveRange
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InclusiveRange
impl Debug for InclusiveRange
Source§impl Display for InclusiveRange
impl Display for InclusiveRange
Source§impl From<InclusiveRange> for ClosedRange
impl From<InclusiveRange> for ClosedRange
Source§fn from(r: InclusiveRange) -> Self
fn from(r: InclusiveRange) -> Self
Converts to this type from the input type.
Source§impl From<InclusiveRange> for DownloadRange
impl From<InclusiveRange> for DownloadRange
Source§fn from(r: InclusiveRange) -> Self
fn from(r: InclusiveRange) -> Self
Converts to this type from the input type.
Source§impl From<InclusiveRange> for Range<u64>
impl From<InclusiveRange> for Range<u64>
Source§fn from(ir: InclusiveRange) -> Self
fn from(ir: InclusiveRange) -> Self
Converts to this type from the input type.
Source§impl From<InclusiveRange> for RangeInclusive<u64>
impl From<InclusiveRange> for RangeInclusive<u64>
Source§fn from(ir: InclusiveRange) -> Self
fn from(ir: InclusiveRange) -> Self
Converts to this type from the input type.
Source§impl From<RangeInclusive<u64>> for InclusiveRange
impl From<RangeInclusive<u64>> for InclusiveRange
Source§fn from(ri: RangeInclusive<u64>) -> Self
fn from(ri: RangeInclusive<u64>) -> Self
Converts to this type from the input type.
Source§impl From<RangeToInclusive<u64>> for InclusiveRange
impl From<RangeToInclusive<u64>> for InclusiveRange
Source§fn from(ri: RangeToInclusive<u64>) -> Self
fn from(ri: RangeToInclusive<u64>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for InclusiveRange
impl PartialEq for InclusiveRange
impl Copy for InclusiveRange
impl Eq for InclusiveRange
impl StructuralPartialEq for InclusiveRange
Auto Trait Implementations§
impl Freeze for InclusiveRange
impl RefUnwindSafe for InclusiveRange
impl Send for InclusiveRange
impl Sync for InclusiveRange
impl Unpin for InclusiveRange
impl UnwindSafe for InclusiveRange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more