(
zelf: &Py<Self>,
other: &PyObject,
op: PyComparisonOp,
_vm: &VirtualMachine,
)
| 497 | |
| 498 | impl Comparable for PyRange { |
| 499 | fn cmp( |
| 500 | zelf: &Py<Self>, |
| 501 | other: &PyObject, |
| 502 | op: PyComparisonOp, |
| 503 | _vm: &VirtualMachine, |
| 504 | ) -> PyResult<PyComparisonValue> { |
| 505 | op.eq_only(|| { |
| 506 | if zelf.is(other) { |
| 507 | return Ok(true.into()); |
| 508 | } |
| 509 | let rhs = class_or_notimplemented!(Self, other); |
| 510 | let lhs_len = zelf.compute_length(); |
| 511 | let eq = if lhs_len != rhs.compute_length() { |
| 512 | false |
| 513 | } else if lhs_len.is_zero() { |
| 514 | true |
| 515 | } else if zelf.start.as_bigint() != rhs.start.as_bigint() { |
| 516 | false |
| 517 | } else if lhs_len.is_one() { |
| 518 | true |
| 519 | } else { |
| 520 | zelf.step.as_bigint() == rhs.step.as_bigint() |
| 521 | }; |
| 522 | Ok(eq.into()) |
| 523 | }) |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | impl Iterable for PyRange { |
nothing calls this directly
no test coverage detected