8000 Move macro to protocol/iter.rs · RustPython/RustPython@9184d7c · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 9184d7c

Browse files
committed
Move macro to protocol/iter.rs
1 parent 10a8566 commit 9184d7c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

vm/src/protocol/iter.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,15 @@ where
276276
(self.length_hint.unwrap_or(0), self.length_hint)
277277
}
278278
}
279+
280+
#[macro_export]
281+
macro_rules! handle_pyiter_return {
282+
($input:expr) => {
283+
match $input {
284+
$crate::protocol::PyIterReturn::Return(obj) => obj,
285+
$crate::protocol::PyIterReturn::StopIteration(v) => {
286+
return Ok($crate::protocol::PyIterReturn::StopIteration(v))
287+
}
288+
}
289+
};
290+
}

vm/src/stdlib/itertools.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
pub(crate) use decl::make_module;
22

3-
macro_rules! handle_pyiter_return {
4-
($input:expr) => {
5-
match $input {
6-
PyIterReturn::Return(obj) => obj,
7-
PyIterReturn::StopIteration(v) => return Ok(PyIterReturn::StopIteration(v)),
8-
}
9-
};
10-
}
11-
123
#[pymodule(name = "itertools")]
134
mod decl {
145
use crate::stdlib::itertools::decl::int::get_value;
@@ -25,7 +16,7 @@ mod decl {
2516
},
2617
convert::ToPyObject,
2718
function::{ArgCallable, ArgIntoBool, FuncArgs, OptionalArg, OptionalOption, PosArgs},
28-
identifier,
19+
handle_pyiter_return, identifier,
2920
protocol::{PyIter, PyIterReturn, PyNumber},
3021
stdlib::sys,
3122
types::{Constructor, IterNext, Iterable, Representable, SelfIter},

0 commit comments

Comments
 (0)
0