mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add index function to operator module
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::builtins::int::PyIntRef;
|
||||
use crate::builtins::pystr::PyStrRef;
|
||||
use crate::byteslike::PyBytesLike;
|
||||
use crate::common::cmp;
|
||||
@@ -43,10 +44,15 @@ fn _operator_compare_digest(
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
fn _operator_index(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyIntRef> {
|
||||
vm.to_index(&obj)
|
||||
}
|
||||
|
||||
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
let ctx = &vm.ctx;
|
||||
py_module!(vm, "_operator", {
|
||||
"length_hint" => named_function!(ctx, _operator, length_hint),
|
||||
"_compare_digest" => named_function!(ctx, _operator, compare_digest),
|
||||
"index" => named_function!(ctx, _operator, index),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user