pub struct RangeSet { /* private fields */ }Expand description
An ordered set of integer string representations, supporting cluster
range notation like "1-10,15,20-30/2".
Implementations§
Source§impl RangeSet
impl RangeSet
Sourcepub fn parse(pattern: &str, autostep: Option<u32>) -> Result<Self>
pub fn parse(pattern: &str, autostep: Option<u32>) -> Result<Self>
Parse a range set from a string pattern like "1-4,6,8-12/2".
autostep is the user-facing autostep threshold (minimum element count
to trigger step folding). Pass None to disable.
Sourcepub fn add_range(&mut self, start: i64, stop: i64, step: i64, pad: u32)
pub fn add_range(&mut self, start: i64, stop: i64, step: i64, pad: u32)
Add a range of integers [start, stop) with given step and padding.
Sourcepub fn add_int(&mut self, value: i64, pad: u32)
pub fn add_int(&mut self, value: i64, pad: u32)
Add an integer element with optional zero-padding.
Sourcepub fn remove_str(&mut self, s: &str)
pub fn remove_str(&mut self, s: &str)
Remove an element by string. Panics if not present.
Sourcepub fn discard_str(&mut self, s: &str)
pub fn discard_str(&mut self, s: &str)
Remove an element by string if present (no error).
Sourcepub fn contains_str(&self, s: &str) -> bool
pub fn contains_str(&self, s: &str) -> bool
Check if a string element is in the set.
Sourcepub fn contains_int(&self, value: i64) -> bool
pub fn contains_int(&self, value: i64) -> bool
Check if an integer (unpadded) is in the set.
Sourcepub fn intersection(&self, other: &RangeSet) -> RangeSet
pub fn intersection(&self, other: &RangeSet) -> RangeSet
Return the intersection of two range sets.
Sourcepub fn difference(&self, other: &RangeSet) -> RangeSet
pub fn difference(&self, other: &RangeSet) -> RangeSet
Return the difference (self - other).
Sourcepub fn symmetric_difference(&self, other: &RangeSet) -> RangeSet
pub fn symmetric_difference(&self, other: &RangeSet) -> RangeSet
Return the symmetric difference.
Sourcepub fn intersection_update(&mut self, other: &RangeSet)
pub fn intersection_update(&mut self, other: &RangeSet)
Update self to be the intersection with other.
Sourcepub fn difference_update(&mut self, other: &RangeSet)
pub fn difference_update(&mut self, other: &RangeSet)
Update self to be self - other.
Sourcepub fn symmetric_difference_update(&mut self, other: &RangeSet)
pub fn symmetric_difference_update(&mut self, other: &RangeSet)
Update self to be the symmetric difference with other.
Sourcepub fn autostep(&self) -> Option<u32>
pub fn autostep(&self) -> Option<u32>
Get autostep value (user-facing: minimum node count, or None if disabled).
Sourcepub fn set_autostep(&mut self, val: Option<u32>)
pub fn set_autostep(&mut self, val: Option<u32>)
Set autostep value (user-facing: minimum node count, or None to disable).