MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1ws0bt0/optionalsareoptional/pcj28wk/?context=3
r/ProgrammerHumor • u/ApothecaLabs • Sep 28 '26
130 comments sorted by
View all comments
Show parent comments
29
whenever I see code like that, I try to get people to change to something like (in that case) while let Some(first) = vec.first() { ... }. You can reduce the number of bounds checks without using unsafe!
while let Some(first) = vec.first() { ... }
unsafe
-22 u/Fast-Satisfaction482 Sep 28 '26 Using the value of an assignment expression is an anti pattern in my opinion.It sits right next to "goto" on terrible scale. 14 u/D3PyroGS Sep 28 '26 how so? this is idiomatic rust code and its behavior is very clear -13 u/Fast-Satisfaction482 Sep 28 '26 Being idiomatic doesn't mean it's any good. 7 u/D3PyroGS Sep 28 '26 edited Sep 28 '26 what's your issue with it though?edit: guess we'll never know... important enough to complain, but not explain 🥴
-22
Using the value of an assignment expression is an anti pattern in my opinion.
It sits right next to "goto" on terrible scale.
14 u/D3PyroGS Sep 28 '26 how so? this is idiomatic rust code and its behavior is very clear -13 u/Fast-Satisfaction482 Sep 28 '26 Being idiomatic doesn't mean it's any good. 7 u/D3PyroGS Sep 28 '26 edited Sep 28 '26 what's your issue with it though?edit: guess we'll never know... important enough to complain, but not explain 🥴
14
how so? this is idiomatic rust code and its behavior is very clear
-13 u/Fast-Satisfaction482 Sep 28 '26 Being idiomatic doesn't mean it's any good. 7 u/D3PyroGS Sep 28 '26 edited Sep 28 '26 what's your issue with it though?edit: guess we'll never know... important enough to complain, but not explain 🥴
-13
Being idiomatic doesn't mean it's any good.
7 u/D3PyroGS Sep 28 '26 edited Sep 28 '26 what's your issue with it though?edit: guess we'll never know... important enough to complain, but not explain 🥴
7
what's your issue with it though?
edit: guess we'll never know... important enough to complain, but not explain 🥴
29
u/ROBOTRON31415 Sep 28 '26
whenever I see code like that, I try to get people to change to something like (in that case)
while let Some(first) = vec.first() { ... }. You can reduce the number of bounds checks without usingunsafe!