pub struct Range {
pub low: usize,
pub high: usize,
}Expand description
A range of values
Fields§
§low: usizeThe lower bound of the range
high: usizeThe upper bound of the range
Implementations§
Trait Implementations§
Source§impl FromStr for Range
impl FromStr for Range
Source§fn from_str(s: &str) -> Result<Self, &'static str>
fn from_str(s: &str) -> Result<Self, &'static str>
Parse a string of the form a-b into a Range
use std::str::FromStr;
use uucore::ranges::Range;
assert_eq!(Range::from_str("5"), Ok(Range { low: 5, high: 5 }));
assert_eq!(Range::from_str("4-"), Ok(Range { low: 4, high: usize::MAX - 1 }));
assert_eq!(Range::from_str("-4"), Ok(Range { low: 1, high: 4 }));
assert_eq!(Range::from_str("2-4"), Ok(Range { low: 2, high: 4 }));
assert!(Range::from_str("0-4").is_err());
assert!(Range::from_str("4-2").is_err());
assert!(Range::from_str("-").is_err());
assert!(Range::from_str("a").is_err());
assert!(Range::from_str("a-b").is_err());Source§impl Ord for Range
impl Ord for Range
Source§impl PartialOrd for Range
impl PartialOrd for Range
impl Eq for Range
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl Freeze for Range
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnwindSafe for Range
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