๐ฆ I got surprised by calling last() on a DoubleEndedIterator. Now, itโs a Clippy lint!
qsantos.fr/2025/01/01/r...
@qsantos.fr.bsky.social
๐ซ๐ท French ๐ฆ Rust enthusiast ๐ฏ๐ต Japanese learner (N1) ๐ป Interested in amateur radio Programming stuff (not just Rust): https://github.com/qsantos
๐ฆ I got surprised by calling last() on a DoubleEndedIterator. Now, itโs a Clippy lint!
qsantos.fr/2025/01/01/r...
My current computer is about as powerful as the 500th most powerful supercomputer in 2004.
14.12.2024 07:53 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Mostly agreed. Coming from Python and its generator, I feel like implementing iterators could be made easier. But maybe coroutines will be stabilized one day.
12.12.2024 20:06 โ ๐ 1 ๐ 0 ๐ฌ 1 ๐ 0Mostly in Iterator::next so far
09.12.2024 19:35 โ ๐ 1 ๐ 0 ๐ฌ 0 ๐ 0Eh, on this specific one, I often oppose YAGNI to abuse DRY.
09.12.2024 17:02 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0I have often seen confusion between str and String in #Rustlang. Maybe this will help.
09.12.2024 15:07 โ ๐ 4 ๐ 0 ๐ฌ 0 ๐ 0Out of curiosity, are you coming from a previous programming language?
From looking at the struggles of people with Rust, I have the feeling that it is often about lower-level programming concepts, not about Rust specifically. And learning these concepts with C++ would definitely be more painful.
I basically stumbled upon it when I started getting comfortable with the let-else operator, and Clippy suggested an even better way.
doc.rust-lang.org/rust-by-exam...
I had learned, but not internalized the fact that you can use ? on Option<T>. This makes some patterns much more readable, in particular when implementing the Iterator trait.
github.com/rust-lang/ru...
When you are at the point where you are still grappling with = vs == and that you cannot use variables before declaring them, move semantics, lifetime and/or generic traits is just gibberish. You can avoid some of it with String and clone() everywhere, but that also make things less intuitive.
07.12.2024 19:36 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0If the alternative is starting with C++, definitely. However, for a true beginner, Rust puts many concepts up-front, which can be overwhelming.
07.12.2024 19:36 โ ๐ 0 ๐ 0 ๐ฌ 1 ๐ 0Don't learn a language. Do a project in that language. Ideally, something random, where you can just experiment with weird programming ideas that could come up while ramping up on the language.
07.12.2024 14:55 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0I think that experiencing C++ can actually help understand some of the design decisions of Rust, so not a bad idea all in all.
07.12.2024 02:48 โ ๐ 2 ๐ 0 ๐ฌ 0 ๐ 0> is there a such thing as learning to many languages at once?
No, as long as it is Rust!
For instance, let age: i32 = age.parse()?; is pretty neat. Without shadowing, you resort to encode part of the type in the name, which is distracting, and not that useful when you have rust-analyzer annotations.
04.12.2024 20:29 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0You should definitely not over-do-it, but it works pretty well when you are just changing the type of what is conceptually the same thing.
04.12.2024 20:29 โ ๐ 1 ๐ 0 ๐ฌ 1 ๐ 0I have come to accept that default arguments are well-ish with the builder pattern. But it's definitely something to get used to. No missing argument, however, I still find it annoying. Thankfully, rust-analyzer adds them back as annotations.
04.12.2024 20:26 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Just use HTML for both the backend and the frontend
04.12.2024 20:25 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Does that include rust-analyzer? If so, that sounds high!
04.12.2024 20:23 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Oh, right, I missed that the quoting post was also from the other place!
04.12.2024 07:35 โ ๐ 1 ๐ 0 ๐ฌ 0 ๐ 0I was going to refer to the time I took the Shinkansen the wrong way for 130km, but you actually did that intentionally. It _is_ clever!
04.12.2024 07:34 โ ๐ 1 ๐ 0 ๐ฌ 1 ๐ 0Out of curiosity, what are you using nightly for?
04.12.2024 07:32 โ ๐ 0 ๐ 0 ๐ฌ 1 ๐ 0I'd say it sucks in the right way: if I understand, the segfault is actually a panic, which tells you where the error occurred, while C or C++ might run happily for a while with corrupted memory.
Anyway I can help by having a look at some code?
In any case, good luck with what you're doing!
Did you know that #RustLang lets you move !Unpin values?
04.12.2024 06:51 โ ๐ 8 ๐ 1 ๐ฌ 0 ๐ 0It sill hallucinated a typo, but it did pretty well; much better than previous versions.
04.12.2024 06:46 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0Another one:
> "Box::heap" in "like you would do with Box::heap" should likely be "Box::pin."
I still would not trust it blindly, but it is definitely useful for findings things you can then check for yourself.
04.12.2024 06:44 โ ๐ 0 ๐ 0 ๐ฌ 1 ๐ 0Checking typos with #ChatGPT 4o feels a bit magical:
> "Poll::Read(()),"should be "Poll::Ready(())."