mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Remove unused _membership_iter_search (#6318)
This commit is contained in:
@@ -28,8 +28,6 @@ enum SearchType {
|
||||
Index,
|
||||
}
|
||||
|
||||
// Note: might be a good idea to merge with _membership_iter_search or generalize (_sequence_iter_check?)
|
||||
// and place in vm.rs for all sequences to be able to use it.
|
||||
#[inline]
|
||||
fn iter_search(
|
||||
obj: &PyObject,
|
||||
|
||||
@@ -2,9 +2,9 @@ use super::VirtualMachine;
|
||||
use crate::stdlib::warnings;
|
||||
use crate::{
|
||||
PyRef,
|
||||
builtins::{PyInt, PyIntRef, PyStr, PyStrRef, PyUtf8Str},
|
||||
builtins::{PyInt, PyStr, PyStrRef, PyUtf8Str},
|
||||
object::{AsObject, PyObject, PyObjectRef, PyResult},
|
||||
protocol::{PyIterReturn, PyNumberBinaryOp, PyNumberTernaryOp, PySequence},
|
||||
protocol::{PyNumberBinaryOp, PyNumberTernaryOp, PySequence},
|
||||
types::PyComparisonOp,
|
||||
};
|
||||
use num_traits::ToPrimitive;
|
||||
@@ -529,26 +529,6 @@ impl VirtualMachine {
|
||||
self.format(obj, format_spec)?.try_into_utf8(self)
|
||||
}
|
||||
|
||||
// https://docs.python.org/3/reference/expressions.html#membership-test-operations
|
||||
fn _membership_iter_search(
|
||||
&self,
|
||||
haystack: &PyObject,
|
||||
needle: PyObjectRef,
|
||||
) -> PyResult<PyIntRef> {
|
||||
let iter = haystack.get_iter(self)?;
|
||||
loop {
|
||||
if let PyIterReturn::Return(element) = iter.next(self)? {
|
||||
if self.bool_eq(&element, &needle)? {
|
||||
return Ok(self.ctx.new_bool(true));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return Ok(self.ctx.new_bool(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _contains(&self, haystack: &PyObject, needle: &PyObject) -> PyResult<bool> {
|
||||
let seq = haystack.to_sequence();
|
||||
seq.contains(needle, self)
|
||||
|
||||
Reference in New Issue
Block a user