Checks that the multiplication is able to be performed. On Ok returns the index as a usize for sequences to be able to use immediately.
(&self, length: usize, n: isize)
| 156 | /// Checks that the multiplication is able to be performed. On Ok returns the |
| 157 | /// index as a usize for sequences to be able to use immediately. |
| 158 | pub fn check_repeat_or_overflow_error(&self, length: usize, n: isize) -> PyResult<usize> { |
| 159 | if n <= 0 { |
| 160 | Ok(0) |
| 161 | } else { |
| 162 | let n = n as usize; |
| 163 | if length > crate::stdlib::sys::MAXSIZE as usize / n { |
| 164 | Err(self.new_overflow_error("repeated value are too long")) |
| 165 | } else { |
| 166 | Ok(n) |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /// Calling scheme used for binary operations: |
| 172 | /// |