Method
__add__
(
zelf: PyRef<Self>,
other: PyObjectRef,
vm: &VirtualMachine,
)
Source from the content-addressed store, hash-verified
| 369 | )] |
| 370 | impl PyTuple { |
| 371 | fn __add__( |
| 372 | zelf: PyRef<Self>, |
| 373 | other: PyObjectRef, |
| 374 | vm: &VirtualMachine, |
| 375 | ) -> PyArithmeticValue<PyRef<Self>> { |
| 376 | let added = other.downcast::<Self>().map(|other| { |
| 377 | if other.elements.is_empty() && zelf.class().is(vm.ctx.types.tuple_type) { |
| 378 | zelf |
| 379 | } else if zelf.elements.is_empty() && other.class().is(vm.ctx.types.tuple_type) { |
| 380 | other |
| 381 | } else { |
| 382 | let elements = zelf |
| 383 | .iter() |
| 384 | .chain(other.as_slice()) |
| 385 | .cloned() |
| 386 | .collect::<Box<[_]>>(); |
| 387 | Self { elements }.into_ref(&vm.ctx) |
| 388 | } |
| 389 | }); |
| 390 | PyArithmeticValue::from_option(added.ok()) |
| 391 | } |
| 392 | |
| 393 | #[pymethod] |
| 394 | fn count(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> { |
Callers
nothing calls this directly
Tested by
no test coverage detected