title: Confusion about lifetime and borrows in a nested for loop in a method
body: <p>I am trying to make a stack of cards. So I have structs for cards and suits. But when I try to initialize all combinations of cards to make the cardstack it has a problem with borrows and lifetimes.
  I can't for the life of me understand how to solve this issue. And yes, I already read the chapters on lifetimes etc.</p>
  <p>The errors start at the line at the end, where the parameters for Card::new does not have the right lifetime. But I don't know how to put correc lifetime on these:</p>
  <pre><code>stackvector.push(Card::new(cardsuit, number))
  </code></pre>
  <pre><code>use rand::thread_rng;
  use strum::IntoEnumIterator;
  use strum_macros::EnumIter;
  
  #[allow(dead_code)]
  #[derive(Debug, PartialEq, EnumIter)]
  pub enum CardSuits {
      Hearts,
      Spades,
      Diamonds,
      Clubs,
  }
  
  #[derive(Debug, PartialEq)]
  pub struct Card&lt;'a&gt; {
      pub suit: &amp;'a CardSuits,
      pub number: &amp;'a u32,
  }
  
  impl&lt;'a&gt; Card&lt;'a&gt;  {
      pub fn new(new_suit: &amp;'a CardSuits, new_number: &amp;'a u32) -&gt; Self {
          Card { suit: new_suit, number: new_number }
      }
  }
  
  pub struct CardStack&lt;'a&gt; {
      pub stack: &amp;'a Vec&lt;Card&lt;'a&gt;&gt;,
  }
  
  impl&lt;'a&gt; CardStack&lt;'a&gt; {
      pub fn new(cardsuits: CardSuitsIter, stackvector: &amp;'a mut Vec&lt;Card&gt;) -&gt; Self {
          
          for cardsuit in cardsuits {
              for number in (1..=13).into_iter() {
                  stackvector.push(Card::new(cardsuit, number))
              }
          }
          Self { stack: stackvector }
      }
  }
  </code></pre>