mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add str.__reversed__ method
This commit is contained in:
@@ -1102,6 +1102,16 @@ impl PyString {
|
||||
string: zelf,
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethod(name = "__reversed__")]
|
||||
fn reversed(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyStringReverseIterator {
|
||||
let begin = zelf.value.chars().count();
|
||||
|
||||
PyStringReverseIterator {
|
||||
position: Cell::new(begin),
|
||||
string: zelf,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PyValue for PyString {
|
||||
|
||||
Reference in New Issue
Block a user