1
struct MyStruct<'a> {
    items: Vec<i32>;
    iter: Cycle<std::slice::Iter<'a, i32>;
}

fn main() {
    let v = vec![1, 2, 3];

    let foo = MyStruct {
        items: v,
        iter: items.iter().cycle();
    };
}

Rust says that it doesn't know name items.

How to do it correctly?

vladon
  • 8,158
  • 2
  • 47
  • 91
  • 1
    what is the `iter` field for? Is this different in another instance of MyStruct? Otherwise, would turning this into a function [like this](http://play.integer32.com/?gist=7420fddff427fd7c01873f121235b238&version=stable) solve your case? – hansaplast Dec 30 '16 at 21:43
  • @hansaplast I need to save current position, i.e. iterator value. – vladon Dec 30 '16 at 21:48
  • in addition to the duplicate this question points to, [this](http://stackoverflow.com/questions/25269597/how-to-initialize-struct-fields-which-reference-each-other) might also serve as a help on how to solve this – hansaplast Dec 31 '16 at 10:52

0 Answers0