forked from Rust-related/RustPython
TryFromBorrowedObject for &str
This commit is contained in:
@@ -48,6 +48,13 @@ impl<'a> TryFromBorrowedObject<'a> for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFromBorrowedObject<'a> for &'a str {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
|
||||
let pystr: &Py<PyStr> = TryFromBorrowedObject::try_from_borrowed_object(vm, obj)?;
|
||||
Ok(pystr.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
#[pyclass(module = false, name = "str")]
|
||||
pub struct PyStr {
|
||||
bytes: Box<[u8]>,
|
||||
|
||||
Reference in New Issue
Block a user