Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 581 Bytes

README.md

File metadata and controls

34 lines (25 loc) · 581 Bytes
by just-do-halee

Today I learned

2022-11-30


  • Rust::Alloc

    • ::Vec

      _ = vec![1,2,3,4,5];
      // same as Box::new([1,2,3,4,5]).into_vec();
      // so the capacity is 5 as .len()
      struct ClonableStruct;
      impl Clone for ClonableStruct {
          fn clone(&self) -> Self {
              eprintln!("cloned!");
              Self
          }
      }
      _ = vec![ClonableStruct; 10];
      // will print out "cloned!" 9 times
      // first one is just original