**Schleifen** **3. Loop** Im Prinzip schon angekündigt, wird sich das Schleifenthema als Haupttrakt mit diesem Abschnitt beenden. *Loop* ist eine Endlosschleife und kann nur durch ein gezieltes *Break* abgebrochen werden. Es reicht vollkommen aus, den Inhalt von *loop* in geschweifte Klammern zu setzen und schon hört es nicht mehr auf. ``` fn main (){ loop{ print!("Endlosschleife - "); } } ``` Ausgabe (Ausschnitt)  Das ist natürlich nicht übermäßig nützlich, zeigt aber verkürzt, wie es funktioniert. Was ist aber der Einsatzort einer solchen *Loop-Schleife*? Kurz gesagt, kann man sie überall dort brauchen, wo ein Programm am Laufen gehalten werden soll. Obwohl ich keine Ahnung von der Entwicklung eines Betriebssystems habe, würde ich davon ausgehen, dass *loop*(s) hier nötig sind, denn ansonsten (nachdem in der Programmierung vorgesehen ist, dass es sich von oben nach unten durcharbeitet), wäre wohl schon bald Schluss, wenn die Basis nicht aufrechterhalten wird. Im Laufe der Zeit werde ich vermutlich auch vermehrt darauf zurückgreifen, aber bis jetzt schreibe ich noch nicht so große Programme, dass ich es brauchen würde ... Aber mal sehen, es ist gut, so etwas in petto zu haben. Um auch auf die Iteration einzugehen ``` let mut x=0; loop{ x=x+1; print!(" x: {} - ",x); } ``` Ausgabe (Ausschnitt)  Die Bandbreite des *i32* fängt einfach immer wieder von vorne an. Wie bei der *while true* Schleife. Eine nützliche Besonderheit der *loop*-Schleife möchte ich nicht vorenthalten. Diese lassen sich nämlich auch einen Namen geben. Einfach mit 'name_der_Schleife: loop;' Wenn mehrere *loops* am Laufen sind, können diese durch ihre Namen mit break 'name_der_Schleife abgebrochen werden. ``` 'loop_gesamt: loop{ println!("Hier beginnen die Geschichten von x und y"); let mut x =0; 'loop_x: loop{ x=x+1; if x <=10{ println!("{}. x geht noch weiter.",x); } else{ println!("Das ist das Ende von x"); break 'loop_x; } } let mut y =0; 'loop_y: loop{ y=y+1; if y <=10{ println!("{}. y geht noch weiter.",y); } else{ println!("Das ist das Ende von y"); break 'loop_y; } } println!("Das ist das Ende vom Lied von x und y"); break 'loop_gesamt; } ``` Zugegeben, das sieht hier etwas viel aus. Es ist sogar anders, als ich ursprünglich gedacht habe. Bei diesem Beispiel habe ich selbst einiges dazu gelernt. Vor allem in welche Richtungen die Gedanken beim Programmieren laufen sollten. *Entspricht das was ich will, dem was ich will? *Weiß ich etwas nicht, oder ist die Methode falsch, die ich anwende? *Wenn ich die richtige Methode anwende, warum funktioniert es nicht? *Sind meine Annahmen über die Methode richtig? Da gäbe es wahrscheinlich noch ein paar so ähnlich klingende Überlegungen, die allesamt ähnlich klingen, aber trotzdem für einen Zweck essentiell sind. <u>Also, was macht dieser Codeblock?</u> In Summe gibt es 3 Endlosschleifen, die per *break* mit dem jeweiligen Schleifennamen abgebrochen werden. *loop_gesamt *loop_x *loop_y loop_gesamt bricht ab, wenn die loops von x und y durchgelaufen sind. Im übrigen das letzte Break, darf nicht vor der *println!*-Anweisung stehen, sonst bekommt man diese nie vor Gesicht. loop_x lauft bis 10, wird dann abgebrochen und geht weiter auf loop_y. Das widerrum bricht auch bei 10 ab und dadurch geht der Code zum Schleifende von loop_gesamt. Die Ausgabe sieht dann so aus:  Heute kann ich keine gesamte Ausgabe zeigen, weil Endlosschleifen logischerweise dafür nicht geeignet sind. Aber natürlich, wie mein Quellcode aussieht, obwohl er so nicht vernüftig ausführbar wäre. ``` fn main (){ loop{ print!("Endlosschleife - "); } let mut x=0; loop{ x=x+1; print!(" x: {} - ",x); } 'loop_gesamt: loop{ println!("Hier beginnen die Geschichten von x und y"); let mut x =0; 'loop_x: loop{ x=x+1; if x <=10{ println!("{}. x geht noch weiter.",x); } else{ println!("Das ist das Ende von x"); break 'loop_x; } } let mut y =0; 'loop_y: loop{ y=y+1; if y <=10{ println!("{}. y geht noch weiter.",y); } else{ println!("Das ist das Ende von y"); break 'loop_y; } } println!("Das ist das Ende vom Lied von x und y"); break 'loop_gesamt; } } ``` 
author | jeyf123 |
---|---|
permlink | reflexionen-uber-die-programmiersprache-rust-13 |
category | deutsch |
json_metadata | {"app":"peakd/2025.1.2","format":"markdown","tags":["deutsch","hive-engine","cc","rust","loop","programmierung","development"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/jeyf123/23swq4zmShNJe5MkcbLqcL2jVoSkh5cq3n1mYz1zdmEk7EgsE1gFR2J8NQ2x8pGBBa6G5.png","https://files.peakd.com/file/peakd-hive/jeyf123/23swpgUCx94cCEeUieUbQ5xAENCYSRuc4rxaRfN5qgWoJwqaMGJqnrdZcNZwj9NQY4Cf4.png","https://files.peakd.com/file/peakd-hive/jeyf123/23u5XKkMQFeqFzN3R9ykHhW119cjhsUjJqbuRkgQRu5eLa1HZQiHYEmi1zRpGWjG57HZf.png","https://files.peakd.com/file/peakd-hive/jeyf123/Eo2BpKHNVyKHMMX3WugfS2Xx3uXLoHCmQrsPtdgVJn2k5M2dvwFT2nnph4pvoUwAenj.png"]} |
created | 2025-01-12 14:30:00 |
last_update | 2025-01-12 14:30:00 |
depth | 0 |
children | 12 |
last_payout | 2025-01-19 14:30:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.995 HBD |
curator_payout_value | 1.988 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 5,413 |
author_reputation | 85,478,775,140,422 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 139,939,437 |
net_rshares | 6,269,471,305,900 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
fabio | 0 | 723,207,092,907 | 50% | ||
freiheit50 | 0 | 693,878,565 | 99% | ||
orionvk | 0 | 5,158,844,419 | 100% | ||
lunix | 0 | 2,350,722,045 | 100% | ||
lifestylechill | 0 | 16,212,258,714 | 50% | ||
dashforcenews-de | 0 | 42,215,553,384 | 40% | ||
vikisecrets | 0 | 780,328,137,812 | 33% | ||
reiseamateur | 0 | 271,254,651,750 | 50.7% | ||
udabeu | 0 | 35,296,627,374 | 33% | ||
condeas | 0 | 307,138,689,068 | 20% | ||
freiheitsbote | 0 | 6,549,673,951 | 70% | ||
indextrader24 | 0 | 14,546,766,037 | 50% | ||
fw206 | 0 | 2,560,691,307,536 | 34% | ||
meins0815 | 0 | 10,592,923,833 | 23% | ||
crimo | 0 | 580,667,248 | 11.5% | ||
dash-embassy | 0 | 3,935,833,077 | 50% | ||
alucian | 0 | 2,808,672,582 | 100% | ||
babschnae | 0 | 331,848,830,958 | 100% | ||
kryptodenno | 0 | 627,093,490,891 | 20% | ||
janasilver | 0 | 2,455,028,891 | 100% | ||
shopinbit | 0 | 7,990,639,197 | 50% | ||
tokenindustry | 0 | 1,873,779,108 | 32.67% | ||
voinvote | 0 | 92,777,328,005 | 70% | ||
starthilfe | 0 | 21,998,448,534 | 100% | ||
hive-199963 | 0 | 116,789,528,960 | 100% | ||
herz-ass | 0 | 94,814,929,741 | 100% | ||
ceridwen | 0 | 13,638,432,379 | 100% | ||
noctury | 0 | 2,769,658,477 | 10% | ||
charlissy | 0 | 94,346,021,659 | 100% | ||
carina89 | 0 | 68,331,959,740 | 100% | ||
blackmedschn | 0 | 9,180,929,058 | 28.74% | ||
lolz.byte | 0 | 0 | 100% |
!invest_vote !LUV !PIZZA !wine !WITZ !LOLZ !Hugh
author | indextrader24 |
---|---|
permlink | spzea9 |
category | deutsch |
json_metadata | {"app":"hiveblog/0.1"} |
created | 2025-01-12 15:13:21 |
last_update | 2025-01-12 15:13:21 |
depth | 1 |
children | 10 |
last_payout | 2025-01-19 15:13:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 48 |
author_reputation | 464,462,650,077,594 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 139,940,297 |
net_rshares | 1,474,654,681 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
buildawhale | 0 | -40,268,845,529 | -0.05% | ||
jeyf123 | 0 | 41,743,500,210 | 24% |
Danke dir:)
author | jeyf123 |
---|---|
permlink | re-indextrader24-2025114t53540790z |
category | deutsch |
json_metadata | {"type":"comment","tags":["ecency"],"app":"ecency/3.2.0-mobile","format":"markdown+html"} |
created | 2025-01-14 04:35:39 |
last_update | 2025-01-14 04:35:39 |
depth | 2 |
children | 8 |
last_payout | 2025-01-21 04:35:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.032 HBD |
curator_payout_value | 0.031 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 11 |
author_reputation | 85,478,775,140,422 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 139,984,317 |
net_rshares | 114,434,457,920 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
indextrader24 | 0 | 18,907,806,071 | 100% | ||
voinvote2 | 0 | 95,526,651,849 | 70% |
Frohes Neues !invest_vote !LUV !PIZZA !wine !WITZ !LOLZ !Hugh
author | indextrader24 |
---|---|
permlink | sq5jka |
category | deutsch |
json_metadata | {"app":"hiveblog/0.1"} |
created | 2025-01-15 22:53:00 |
last_update | 2025-01-15 22:53:00 |
depth | 3 |
children | 6 |
last_payout | 2025-01-22 22:53:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 63 |
author_reputation | 464,462,650,077,594 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 140,032,919 |
net_rshares | 0 |
@indextrader24 denkt du hast ein Vote durch @investinthefutur verdient!<br>@indextrader24 thinks you have earned a vote of @investinthefutur !<br>
author | investinthefutur |
---|---|
permlink | re-re-indextrader24-2025114t53540790z-20250115t225322z |
category | deutsch |
json_metadata | "{"app": "beem/0.24.26"}" |
created | 2025-01-15 22:53:21 |
last_update | 2025-01-15 22:53:21 |
depth | 3 |
children | 0 |
last_payout | 2025-01-22 22:53:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 146 |
author_reputation | 135,724,265,253,762 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 140,032,926 |
net_rshares | 0 |
@jeyf123, @indextrader24<sub>(3/5)</sub> sent you LUV. | <a href="https://crrdlx.on.fleek.co/" style="text-decoration:none">tools</a> | <a href="https://discord.gg/K5GvNhcPqR" style="text-decoration:none">discord</a> | <a href="https://peakd.com/c/hive-159259">community </a> | <a href="https://hivewiki.netlify.app" style="text-decoration:none">HiveWiki</a> | <a href="https://ichthys.netlify.app" style="text-decoration:none"><>< daily</a> <center>Made with <a href="https://peakd.com/@luvshares" target="_blank">LUV</a> by <a href="https://hive.blog/@crrdlx" target="_blank">crrdlx</a></center>
author | luvshares |
---|---|
permlink | re-spzea9-20250112t151328z |
category | deutsch |
json_metadata | "{"app": "beem/0.24.26"}" |
created | 2025-01-12 15:13:27 |
last_update | 2025-01-12 15:13:27 |
depth | 2 |
children | 0 |
last_payout | 2025-01-19 15:13:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 614 |
author_reputation | 5,651,102,754,153 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 139,940,300 |
net_rshares | 0 |
@indextrader24 denkt du hast ein Vote durch @investinthefutur verdient!<br>@indextrader24 thinks you have earned a vote of @investinthefutur !<br>
author | investinthefutur |
---|---|
permlink | re-reflexionen-uber-die-programmiersprache-rust-13-20250112t151341z |
category | deutsch |
json_metadata | "{"app": "beem/0.24.26"}" |
created | 2025-01-12 15:13:42 |
last_update | 2025-01-12 15:13:42 |
depth | 1 |
children | 0 |
last_payout | 2025-01-19 15:13:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 146 |
author_reputation | 135,724,265,253,762 |
root_title | "Reflexionen über die Programmiersprache Rust 13" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 139,940,302 |
net_rshares | 0 |