rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

move_semantics4.rs (420B)


      1 fn main() {
      2     // You can optionally experiment here.
      3 }
      4 
      5 #[cfg(test)]
      6 mod tests {
      7     #[test]
      8     fn move_semantics4() {
      9         let mut x = Vec::new();
     10         let y = &mut x;
     11         // `y` used here.
     12         y.push(42);
     13         // The mutable reference `y` is not used anymore,
     14         // therefore a new reference can be created.
     15         let z = &mut x;
     16         z.push(13);
     17         assert_eq!(x, [42, 13]);
     18     }
     19 }