
🌟 - 2023 DAY 6 SOLUTIONS -🌟
2y 6mon ago in advent_of_code@programming.devI'm no rust expert, but:
you can use into_iter() instead of iter() to get owned data (if you're not going to use the original container again). With into_iter() you dont have to deref the values every time which is nice.
Also it's small potatoes, but calling input.lines().collect() allocates a vector (that isnt ever used again) when lines() returns an iterator that you can use directly. You can instead pass lines.next().unwrap() into your functions directly.
Strings have a method called split_whitespace() (also a split_ascii_whitespace()) that returns an iterator over tokens separated by any amount of whitespace. You can then call .collect() with a String turbofish (i'd type it out but lemmy's markdown is killing me) on that iterator. Iirc that ends up being faster because replacing characters with an empty character requires you to shift all the following characters backward each time.
Overall really clean code though. One of my favorite parts of using rust (and pain points of going back to other languages) is the crazy amount of helper functions for common operations on basic types.
Edit: oh yeah, also strings have a .parse() method to converts it to a number e.g. data.parse() where the parse takes a turbo fish of the numeric type. As always, turbofishes arent required if rust already knows the type of the variable it's being assigned to.
What Are Your Favorite Hidden Gem Android Apps?
2y 6mon ago in nostupidquestionsIt's a desktop app, but can sync with self-hosted cloud servers. It's also literally just text/markdown files.
An entire state's population just had its data stolen in a ransomware attack
2y 7mon ago in technology from sea.mashable.comFor sure, but as long as clickbait works they'll keep doing it.
To be fair, "an entire x" does have markedly different connotation than "x". The emphasis is that it's, well, the entirety of x. It's the difference between "i ate the cereal" and "i ate all the cereal".
Permanently Deleted
2y 7mon ago in anime@lemmy.mlI mean yeah, but why? Like what did you like about it?
Claymore (the end was kinda mid)
Genuinely curious - why do you like it? I see this at the top anime of all time. I watched it a few years ago and i thought it was absolutely horrible. Like 2 or 3 out of 10.
I feel like the only reason i can see is "the main character is a bad guy" but that doesnt excuse trope-y terrible writing, flat characters, and mid-2000's animation that aged horribly. Am i missing something?
[News] Steam Deck OLED review: Includes specs on new screen and other improvements
2y 7mon ago in steamdeck@sopuli.xyz from www.polygon.comIf they had made the deck more powerful, the old ones would suddenly have been obsolete.
I'm pretty sure it has more to do with current chip technology not actually changing that much in the, what, 2 years since the deck first released?
Also obsolete is a pretty strong word for what - if it had stronger internals - would likely end up being more expensive than current models.
Modern Warfare 3 download is huge (200GB) due to “increased amount of content”
2y 7mon ago in playstation from www.pcgamesn.comMake them optional lmao. I dont have a 4k screen, havent ever had one, and wont buy one for a very long time. Why am i storing these assets i will never use?
What got you into coding ? (aside from money)
2y 7mon ago in programming@programming.devHonestly, it's because a bunch of programs i used disappointed me (performance, functionality, [being a web app at all], etc.) and i figured it couldnt be that hard to do it better. In some cases i was right, in most i was wrong. As it turns out though, I really like programming so i guess i'm stuck here
Xbox's new policy — say goodbye to unofficial accessories from November thanks to error '0x82d60002'
2y 7mon ago in technology from www.windowscentral.comI mean to be fair, those errors arent really meant for you (the end user) in the first place.
When your language doesn't allow arbitrary expressions in format strings
2y 11mon ago in programming_horror@programming.dev from programming.devWhen your language doesn't support arbitrary expressions in format strings
2y 11mon ago in programming_horror@programming.dev



