Macro seq::seqdef_try
[−]
[src]
macro_rules! seqdef_try { ($id:ident, $typ:ty, $max:expr; $rt:expr => $iterator:expr ) => { ... }; }
The macro seqdef_try! places values from iterator as sequence on stack.
This macro reserves MAX elements on the stack
every time when entering the function context. The upper limit MAX is defined at compile time.
At runtime the sequence is constructed, reading the elements from the iterator and placing them
in the reserved stack-memory. When the function context is left, the stack-memory is released.
The macro seqdef_try! will declare the specified identifier as type Resultx must be checked after construction with seqdef_try!.
Note! No matter the number of elements returned by the iterator, the macro is always reserving stack-memory for MAX elements. If you choose too large, the stack might run out of memory. The iterator provided to the macro may consume the underlying container-elements or clone each element.
Example use std::ptr;
fn large_seq_rollout_on_stack() {
const MAX: usize = 2000;
let large_list: &[i32] = &[42; MAX];
// define x of type Result