From accc67b05a2c911c16d147ff67dbb629c448996e Mon Sep 17 00:00:00 2001 From: Abhishek Bhattacharya Date: Thu, 14 Mar 2019 01:15:02 +0530 Subject: [PATCH] Added doc tests for up_to and down_to panic cases --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ef041be..3cbf665 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { if self.from > x { panic!("Invalid range: upper bound cannot be lesser than lower bound!"); @@ -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 { if self.from < x { panic!("Invalid range: lower bound cannot be lesser than upper bound!");