Skip to content

Commit 5b3cb43

Browse files
committed
fix clippy
1 parent 2d3ea4c commit 5b3cb43

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

vm/src/obj/objlist.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ use std::mem::size_of;
44
use std::ops::DerefMut;
55

66
use crossbeam_utils::atomic::AtomicCell;
7-
use num_traits::ToPrimitive;
87

9-
use super::objint::PyIntRef;
108
use super::objiter;
119
use super::objslice::PySliceRef;
1210
use super::objtype::PyTypeRef;
13-
use crate::bytesinner;
1411
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
1512
use crate::function::OptionalArg;
1613
use crate::pyobject::{
@@ -71,25 +68,6 @@ impl PyList {
7168
pub fn borrow_value_mut(&self) -> PyRwLockWriteGuard<'_, Vec<PyObjectRef>> {
7269
self.elements.write()
7370
}
74-
75-
// TODO: more generic way to do so
76-
pub(crate) fn to_byte_inner(&self, vm: &VirtualMachine) -> PyResult<bytesinner::PyBytesInner> {
77-
let mut elements = Vec::<u8>::with_capacity(self.borrow_value().len());
78-
for elem in self.borrow_value().iter() {
79-
let py_int = PyIntRef::try_from_object(vm, elem.clone()).map_err(|_| {
80-
vm.new_type_error(format!(
81-
"'{}' object cannot be interpreted as an integer",
82-
elem.class().name
83-
))
84-
})?;
85-
let result = py_int
86-
.borrow_value()
87-
.to_u8()
88-
.ok_or_else(|| vm.new_value_error("bytes must be in range (0, 256)".to_owned()))?;
89-
elements.push(result);
90-
}
91-
Ok(elements.into())
92-
}
9371
}
9472

9573
#[derive(FromArgs, Default)]

vm/src/obj/objtuple.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
use crossbeam_utils::atomic::AtomicCell;
2-
use num_traits::ToPrimitive;
32
use std::fmt;
43

5-
use super::objint::PyIntRef;
64
use super::objiter;
75
use super::objtype::PyTypeRef;
86
use crate::common::hash::PyHash;
7+
use crate::function::OptionalArg;
98
use crate::pyobject::{
109
self, BorrowValue, Either, IdProtocol, IntoPyObject, PyArithmaticValue, PyClassImpl,
11-
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
12-
TypeProtocol,
10+
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
1311
};
1412
use crate::sequence::{self, SimpleSeq};
1513
use crate::sliceable::PySliceableSequence;
1614
use crate::slots::{Comparable, Hashable, PyComparisonOp};
1715
use crate::vm::{ReprGuard, VirtualMachine};
18-
use crate::{bytesinner::PyBytesInner, function::OptionalArg};
1916

2017
/// tuple() -> empty tuple
2118
/// tuple(iterable) -> tuple initialized from iterable's items
@@ -69,25 +66,6 @@ impl PyTuple {
6966
pub(crate) fn fast_getitem(&self, idx: usize) -> PyObjectRef {
7067
self.elements[idx].clone()
7168
}
72-
73-
// TODO: more generic way to do so
74-
pub(crate) fn to_bytes_inner(&self, vm: &VirtualMachine) -> PyResult<PyBytesInner> {
75-
let mut elements = Vec::<u8>::with_capacity(self.borrow_value().len());
76-
for elem in self.borrow_value().iter() {
77-
let py_int = PyIntRef::try_from_object(vm, elem.clone()).map_err(|_| {
78-
vm.new_type_error(format!(
79-
"'{}' object cannot be interpreted as an integer",
80-
elem.class().name
81-
))
82-
})?;
83-
let result = py_int
84-
.borrow_value()
85-
.to_u8()
86-
.ok_or_else(|| vm.new_value_error("bytes must be in range (0, 256)".to_owned()))?;
87-
elements.push(result);
88-
}
89-
Ok(elements.into())
90-
}
9169
}
9270

9371
pub type PyTupleRef = PyRef<PyTuple>;

0 commit comments

Comments
 (0)