()
| 1593 | |
| 1594 | impl AsNumber for PyStr { |
| 1595 | fn as_number() -> &'static PyNumberMethods { |
| 1596 | static AS_NUMBER: PyNumberMethods = PyNumberMethods { |
| 1597 | add: Some(|a, b, vm| { |
| 1598 | let Some(a) = a.downcast_ref::<PyStr>() else { |
| 1599 | return Ok(vm.ctx.not_implemented()); |
| 1600 | }; |
| 1601 | let Some(b) = b.downcast_ref::<PyStr>() else { |
| 1602 | return Ok(vm.ctx.not_implemented()); |
| 1603 | }; |
| 1604 | let bytes = a.as_wtf8().py_add(b.as_wtf8()); |
| 1605 | Ok(unsafe { |
| 1606 | let kind = a.kind() | b.kind(); |
| 1607 | PyStr::new_str_unchecked(bytes.into(), kind) |
| 1608 | } |
| 1609 | .to_pyobject(vm)) |
| 1610 | }), |
| 1611 | remainder: Some(|a, b, vm| { |
| 1612 | if let Some(a) = a.downcast_ref::<PyStr>() { |
| 1613 | a.__mod__(b.to_owned(), vm).to_pyresult(vm) |
| 1614 | } else { |
| 1615 | Ok(vm.ctx.not_implemented()) |
| 1616 | } |
| 1617 | }), |
| 1618 | ..PyNumberMethods::NOT_IMPLEMENTED |
| 1619 | }; |
| 1620 | &AS_NUMBER |
| 1621 | } |
| 1622 | } |
| 1623 | |
| 1624 | impl AsSequence for PyStr { |
nothing calls this directly
no test coverage detected