(zelf: PyRef<Self>, other: PyObjectRef, vm: &VirtualMachine)
| 589 | )] |
| 590 | impl PyStr { |
| 591 | fn __add__(zelf: PyRef<Self>, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { |
| 592 | if let Some(other) = other.downcast_ref::<Self>() { |
| 593 | let bytes = zelf.as_wtf8().py_add(other.as_wtf8()); |
| 594 | Ok(unsafe { |
| 595 | // SAFETY: `kind` is safely decided |
| 596 | let kind = zelf.kind() | other.kind(); |
| 597 | Self::new_str_unchecked(bytes.into(), kind) |
| 598 | } |
| 599 | .to_pyobject(vm)) |
| 600 | } else if let Some(radd) = vm.get_method(other.clone(), identifier!(vm, __radd__)) { |
| 601 | // hack to get around not distinguishing number add from seq concat |
| 602 | radd?.call((zelf,), vm) |
| 603 | } else { |
| 604 | Err(vm.new_type_error(format!( |
| 605 | r#"can only concatenate str (not "{}") to str"#, |
| 606 | other.class().name() |
| 607 | ))) |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | fn _contains(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<bool> { |
| 612 | if let Some(needle) = needle.downcast_ref::<Self>() { |
nothing calls this directly
no test coverage detected