Skip to content

Commit 8c28e1e

Browse files
committed
Call method needs &str not &String.
1 parent 4132f33 commit 8c28e1e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

vm/src/obj/objtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn type_call(vm: &mut VirtualMachine, mut args: PyFuncArgs) -> PyResult {
121121
Ok(obj)
122122
}
123123

124-
pub fn get_attribute(vm: &mut VirtualMachine, obj: PyObjectRef, name: &String) -> PyResult {
124+
pub fn get_attribute(vm: &mut VirtualMachine, obj: PyObjectRef, name: &str) -> PyResult {
125125
let cls = obj.typ();
126126
trace!("get_attribute: {:?}, {:?}, {:?}", cls, obj, name);
127127
if let Some(attr) = cls.get_attr(name) {

vm/src/vm.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl VirtualMachine {
138138

139139
// Container of the virtual machine state:
140140
pub fn to_str(&mut self, obj: PyObjectRef) -> PyResult {
141-
self.call_method(obj, "__str__".to_string(), vec![])
141+
self.call_method(obj, "__str__", vec![])
142142
}
143143

144144
pub fn current_frame(&self) -> &Frame {
@@ -327,28 +327,28 @@ impl VirtualMachine {
327327
}
328328

329329
fn _sub(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
330-
self.call_method(a, "__sub__".to_string(), vec![b])
330+
self.call_method(a, "__sub__", vec![b])
331331
}
332332

333333
fn _add(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
334-
self.call_method(a, "__add__".to_string(), vec![b])
334+
self.call_method(a, "__add__", vec![b])
335335
}
336336

337337
fn _mul(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
338-
self.call_method(a, "__mul__".to_string(), vec![b])
338+
self.call_method(a, "__mul__", vec![b])
339339
}
340340

341341
fn _div(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
342-
self.call_method(a, "__truediv__".to_string(), vec![b])
342+
self.call_method(a, "__truediv__", vec![b])
343343
}
344344

345345
fn call_method(
346346
&mut self,
347347
obj: PyObjectRef,
348-
method_name: String,
348+
method_name: &str,
349349
args: Vec<PyObjectRef>,
350350
) -> PyResult {
351-
let func = match self.get_attribute(obj, &method_name) {
351+
let func = match self.get_attribute(obj, method_name) {
352352
Ok(v) => v,
353353
Err(err) => return Err(err),
354354
};
@@ -360,11 +360,11 @@ impl VirtualMachine {
360360
}
361361

362362
fn _pow(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
363-
self.call_method(a, "__pow__".to_string(), vec![b])
363+
self.call_method(a, "__pow__", vec![b])
364364
}
365365

366366
fn _modulo(&mut self, a: PyObjectRef, b: PyObjectRef) -> PyResult {
367-
self.call_method(a, "__mod__".to_string(), vec![b])
367+
self.call_method(a, "__mod__", vec![b])
368368
}
369369

370370
fn execute_binop(&mut self, op: &bytecode::BinaryOperator) -> Option<PyResult> {
@@ -618,7 +618,7 @@ impl VirtualMachine {
618618
None
619619
}
620620

621-
pub fn get_attribute(&mut self, obj: PyObjectRef, attr_name: &String) -> PyResult {
621+
pub fn get_attribute(&mut self, obj: PyObjectRef, attr_name: &str) -> PyResult {
622622
objtype::get_attribute(self, obj.clone(), attr_name)
623623
}
624624

0 commit comments

Comments
 (0)