mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add int.__rlshift__, int.__rrshift__ methods.
This commit is contained in:
@@ -345,6 +345,16 @@ impl PyInt {
|
||||
inner_lshift(self, other, vm)
|
||||
}
|
||||
|
||||
#[pymethod(name = "__rlshift__")]
|
||||
fn rlshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
if !objtype::isinstance(&other, &vm.ctx.int_type()) {
|
||||
return Ok(vm.ctx.not_implemented());
|
||||
}
|
||||
|
||||
let other = other.payload::<PyInt>().unwrap();
|
||||
inner_lshift(other, self, vm)
|
||||
}
|
||||
|
||||
#[pymethod(name = "__rshift__")]
|
||||
fn rshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
if !objtype::isinstance(&other, &vm.ctx.int_type()) {
|
||||
@@ -355,6 +365,16 @@ impl PyInt {
|
||||
inner_rshift(self, other, vm)
|
||||
}
|
||||
|
||||
#[pymethod(name = "__rrshift__")]
|
||||
fn rrshift(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
if !objtype::isinstance(&other, &vm.ctx.int_type()) {
|
||||
return Ok(vm.ctx.not_implemented());
|
||||
}
|
||||
|
||||
let other = other.payload::<PyInt>().unwrap();
|
||||
inner_rshift(other, self, vm)
|
||||
}
|
||||
|
||||
#[pymethod(name = "__xor__")]
|
||||
pub fn xor(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
|
||||
if objtype::isinstance(&other, &vm.ctx.int_type()) {
|
||||
|
||||
Reference in New Issue
Block a user