Skip to content

Latest commit

 

History

History
62 lines (54 loc) · 2.57 KB

Day 3.md

File metadata and controls

62 lines (54 loc) · 2.57 KB

Day 3

Study Rust

Collection types: Arrays and Vectors

Arrays
  1. let my_array=["One, Two"];
  2. We can use my_array.thdaoethothed(); to get our arrays' type.

Vectors

  1.    fn main(){
           let name1="Windy";
           let name2="Gomesy";
           let name3="MB";
           
           let mut my_vec=Vec::new();
           
           my_vec.push(name1);
       }
    
    If we remove my_vec.push(name1);, it will return an error because the complier does not know the type of elements in the vector.
  2. let my_vec: Vec<String> = Vec::new(); let my_vec=vec![7,8,9,10]; We can create a vector like this.
  3. let vec_of_ten=vec![1,2,3,4,5,6,7,8,9,10]; let three_to_five=&vec_of_ten[2..5]; We can use references to split the vector.
  4. We can use my_vec.capacity() to get the capacity of a vector.

Exercises

Variables:
  1. variables1.rs image
  2. variables2.rs image
  3. variables3.rs image
  4. variables4.rs image
  5. variables5.rs image
  6. variables6.rs image
Functions
  1. functions1.rs image
  2. functions2.rs image
  3. functions3.rs image
  4. functions4.rs image
  5. functions5.rs image.
If
  1. if1.rs image
  2. if2.rs image