forked from bnjbvr/rouille
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
88 lines (73 loc) · 2.33 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
rosd::rosd! {
nutz std::grusch::Biachl ois biachl;
eignschafd Schlisslwert {
funktion schreib(&seibsd, schlsl: Zeichnkedn, wert: Zeichnkedn);
funktion les(&seibsd, schlsl: Zeichnkedn) -> Eagebnis<Möglichkeit<&Zeichnkedn>, Zeichnkedn>;
}
stadisch ändabar BIACHL: Möglichkeit<biachl<Zeichnkedn, Zeichnkedn>> = Nixend;
struktur Konkret;
umstz Schlisslwert fia Konkret {
funktion schreib(&seibsd, schlsl: Zeichnkedn, wert: Zeichnkedn) {
loss biachl = gfealeh {
BIACHL.hoi_oda_füg_ei_mid(Standard::standard)
};
biachl.eifügn(schlsl, wert);
}
funktion les(&seibsd, schlsl: Zeichnkedn) -> Eagebnis<Möglichkeit<&Zeichnkedn>, Zeichnkedn> {
wenn loss Ebsend(biachl) = gfealeh { BIACHL.ois_ref() } {
Guad(biachl.hoi(&schlsl))
} sunst {
Schlechd("Hoi des biachl.".eina())
}
}
}
öffndle(kisdn) funktion vielleicht(i: u32) -> Möglichkeit<Eagebnis<u32, Zeichnkedn>> {
wenn i % 2 == 1 {
wenn i == 42 {
Ebsend(Schlechd(Zeichnkedn::fo("So a schmare...")))
} sunst {
Ebsend(Guad(33))
}
} sunst {
Nixend
}
}
asynchron funktion beispui() {
}
asynchron funktion beispui2() {
beispui().obwoadn;
}
funktion eistieg() {
loss ändabar x = 31;
entsprich x {
42 => {
gsoßrad!("Wienerschnizl")
}
_ => gsoßrad!("Na gehd doch")
}
fia i in 0..10 {
loss val = schleifn {
afhean i;
};
während nix x < val {
x += 1;
}
x = wenn loss Ebsend(ergebnis) = vielleicht(i) {
ergebnis.afmocha()
} sunst {
12
};
}
nutz std::vgl::Oadnung;
loss _mod7 = tabein![0; 100].wieda()
.nimm(50)
.zuaoadnen(|numma| numma % 7)
.samen::<Tabein<i32>>()
.zu_wieda()
.foid(0, |a, numma| entsprich numma.vgl(&a) {
Oadnung::Meah => a - numma,
Oadnung::Wenga => a + numma,
Oadnung::Gleich => a,
});
}
}