Files
RustPython/vm/src/obj/objmemory.rs
ZapAnton 0d3b218237 Fixed the 'toplevel_ref_arg' clippy warning
This replaces all the occurrences of the
'let ref var = another_var' with the
'let var = &another_var'

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
2019-02-05 21:45:56 +03:00

27 lines
729 B
Rust

use super::objtype;
use super::super::pyobject::{
PyContext, PyFuncArgs, PyObject, PyObjectPayload, PyObjectRef, PyResult, TypeProtocol,
};
use super::super::vm::VirtualMachine;
pub fn new_memory_view(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(cls, None), (bytes_object, None)]);
vm.ctx.set_attr(&cls, "obj", bytes_object.clone());
Ok(PyObject::new(
PyObjectPayload::MemoryView {
obj: bytes_object.clone(),
},
cls.clone(),
))
}
pub fn init(ctx: &PyContext) {
let memoryview_type = &ctx.memoryview_type;
ctx.set_attr(
&memoryview_type,
"__new__",
ctx.new_rustfunc(new_memory_view),
);
}