2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
9
Task/Compound-data-type/Rust/compound-data-type-1.rust
Normal file
9
Task/Compound-data-type/Rust/compound-data-type-1.rust
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Defines a generic struct where x and y can be of any type T
|
||||
struct Point<T> {
|
||||
x: T,
|
||||
y: T,
|
||||
}
|
||||
fn main() {
|
||||
let p = Point { x: 1.0, y: 2.5 }; // p is of type Point<f64>
|
||||
println!("{}, {}", p.x, p.y);
|
||||
}
|
||||
5
Task/Compound-data-type/Rust/compound-data-type-2.rust
Normal file
5
Task/Compound-data-type/Rust/compound-data-type-2.rust
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
struct Point<T>(T, T);
|
||||
fn main() {
|
||||
let p = Point(1.0, 2.5);
|
||||
println!("{},{}", p.0, p.1);
|
||||
}
|
||||
4
Task/Compound-data-type/Rust/compound-data-type-3.rust
Normal file
4
Task/Compound-data-type/Rust/compound-data-type-3.rust
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
let p = (0.0, 2.4);
|
||||
println!("{},{}", p.0, p.1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue