/
main.rs
51 lines (41 loc) · 786 Bytes
/
main.rs
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
43
44
45
46
47
48
49
50
use std::fs;
use std::path::PathBuf;
fn main() {
println!("Hello, World!")
}
struct Foo {
field_name: String,
count: u8,
}
impl Foo {
pub fn new(bar: String) -> Foo {
Foo {
field_name: bar,
count: 0
}
}
pub fn boop(&mut self) {
let to_add = 1;
self.count += to_add
}
fn returns_tuple(&self) -> (int, bool) {
(1, true)
}
fn consumes_tuple(&self) -> bool {
let (base, should_double) = self.returns_tuple();
if should_double {
base * 2
} else {
base
}
}
}
impl Drop for Foo {
fn drop(&mut self) {
println!("Dropping foo!")
}
}
enum MyOption<T> {
TheresNothingHereMan,
WhoahTheresAThing(T)
}