(
zelf: &Py<Self>,
other: &PyObject,
op: PyComparisonOp,
vm: &VirtualMachine,
)
| 308 | |
| 309 | impl Comparable for PySlice { |
| 310 | fn cmp( |
| 311 | zelf: &Py<Self>, |
| 312 | other: &PyObject, |
| 313 | op: PyComparisonOp, |
| 314 | vm: &VirtualMachine, |
| 315 | ) -> PyResult<PyComparisonValue> { |
| 316 | let other = class_or_notimplemented!(Self, other); |
| 317 | |
| 318 | let ret = match op { |
| 319 | PyComparisonOp::Lt | PyComparisonOp::Le => None |
| 320 | .or_else(|| { |
| 321 | vm.bool_seq_lt(zelf.start_ref(vm), other.start_ref(vm)) |
| 322 | .transpose() |
| 323 | }) |
| 324 | .or_else(|| vm.bool_seq_lt(&zelf.stop, &other.stop).transpose()) |
| 325 | .or_else(|| { |
| 326 | vm.bool_seq_lt(zelf.step_ref(vm), other.step_ref(vm)) |
| 327 | .transpose() |
| 328 | }) |
| 329 | .unwrap_or_else(|| Ok(op == PyComparisonOp::Le))?, |
| 330 | PyComparisonOp::Eq | PyComparisonOp::Ne => { |
| 331 | let eq = vm.identical_or_equal(zelf.start_ref(vm), other.start_ref(vm))? |
| 332 | && vm.identical_or_equal(&zelf.stop, &other.stop)? |
| 333 | && vm.identical_or_equal(zelf.step_ref(vm), other.step_ref(vm))?; |
| 334 | if op == PyComparisonOp::Ne { !eq } else { eq } |
| 335 | } |
| 336 | PyComparisonOp::Gt | PyComparisonOp::Ge => None |
| 337 | .or_else(|| { |
| 338 | vm.bool_seq_gt(zelf.start_ref(vm), other.start_ref(vm)) |
| 339 | .transpose() |
| 340 | }) |
| 341 | .or_else(|| vm.bool_seq_gt(&zelf.stop, &other.stop).transpose()) |
| 342 | .or_else(|| { |
| 343 | vm.bool_seq_gt(zelf.step_ref(vm), other.step_ref(vm)) |
| 344 | .transpose() |
| 345 | }) |
| 346 | .unwrap_or_else(|| Ok(op == PyComparisonOp::Ge))?, |
| 347 | }; |
| 348 | |
| 349 | Ok(PyComparisonValue::Implemented(ret)) |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | impl Representable for PySlice { |
nothing calls this directly
no test coverage detected