-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructs.rs
More file actions
42 lines (34 loc) · 758 Bytes
/
Copy pathStructs.rs
File metadata and controls
42 lines (34 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Structures.
*/
struct Car{
owner: String,
price: u32,
fuel: f32,
milage: f32,
}
fn main(){
let mut newcar:Car = Car{
owner: String::from("RamLal"),
price: 2_000,
fuel: 21.5,
milage: 10.2,
};
let owner1:String = newcar.owner;
println!("{}", owner1);
newcar.owner = "Ganpat".to_string();
println!("{}",newcar.owner);
let mut mycar:Car = Car{
owner: String::from("Ram"),
..newcar
};
println!("{}", mycar.owner);
println!("{}", mycar.price);
let tuple1:(i32,i32) = (1,2);
let tuple2:(i32,i32,i32) = (3,4,5);
struct Tuple1 (i32,i32);
struct Tuple2 (i32,i32,i32);
let t1:Tuple1 = Tuple1(1,2);
//unit struct
struct UNIT;
}