Skip to content
Open
Changes from all commits
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
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ where
/// # Panics
///
/// This function will panic when trying to create a [Range] where the upper bound is less than the lower bound.
///
/// ```should_panic
/// a_range::from(40).up_to(39);
/// ```
pub fn up_to(self, x: Idx) -> Range<Idx, Upwards> {
if self.from > x {
panic!("Invalid range: upper bound cannot be lesser than lower bound!");
Expand All @@ -106,6 +110,10 @@ where
/// # Panics
///
/// This function will panic when trying to create a [Range] where the lower bound is less than the upper bound.
///
/// ```should_panic
/// a_range::from(40).down_to(41);
/// ```
pub fn down_to(self, x: Idx) -> Range<Idx, Downwards> {
if self.from < x {
panic!("Invalid range: lower bound cannot be lesser than upper bound!");
Expand Down