(&'a self, vm: &VirtualMachine)
| 558 | } |
| 559 | |
| 560 | pub fn try_as_utf8<'a>(&'a self, vm: &VirtualMachine) -> PyResult<&'a PyUtf8Str> { |
| 561 | // Check if the string contains surrogates |
| 562 | self.ensure_valid_utf8(vm)?; |
| 563 | // If no surrogates, we can safely cast to PyStr |
| 564 | Ok(unsafe { &*(self as *const _ as *const PyUtf8Str) }) |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | impl Py<PyStr> { |
no test coverage detected