Quentin's Avatar

Quentin

@qsantos.fr.bsky.social

๐Ÿ‡ซ๐Ÿ‡ท French ๐Ÿฆ€ Rust enthusiast ๐Ÿ‡ฏ๐Ÿ‡ต Japanese learner (N1) ๐Ÿ“ป Interested in amateur radio Programming stuff (not just Rust): https://github.com/qsantos

31 Followers  |  23 Following  |  61 Posts  |  Joined: 17.11.2024  |  1.8434

Latest posts by qsantos.fr on Bluesky

Rust Gotcha: last() on DoubleEndedIterator - Quentin Santos tl;dr: donโ€™t call last() on a DoubleEndedIterator Edit: And, now it is a Clippy lint! How do you efficiently get the last part of a space-separated string in Rust? It will be obvious to some, but the ...

๐Ÿฆ€ I got surprised by calling last() on a DoubleEndedIterator. Now, itโ€™s a Clippy lint!

qsantos.fr/2025/01/01/r...

06.01.2025 17:49 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Why is it so hard to buy things that work well?

danluu.com/nothing-works/

16.12.2024 20:19 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

My current computer is about as powerful as the 500th most powerful supercomputer in 2004.

14.12.2024 07:53 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Coroutine in std::ops - Rust The trait implemented by builtin coroutine types.

Mostly 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    ๐Ÿ“Œ 0

Mostly in Iterator::next so far

09.12.2024 19:35 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Eh, on this specific one, I often oppose YAGNI to abuse DRY.

09.12.2024 17:02 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Rust Strings for C Programmers - Quentin Santos This article will quickly explain the Rust types [T; N], &[T; N], &[T], Vec<T>, &Vec<T> with C code, and what the str, &str, String, OsString and CString add. Arrays and Slices Rust C [T; N] (array)Ex...

I have often seen confusion between str and String in #Rustlang. Maybe this will help.

09.12.2024 15:07 โ€” ๐Ÿ‘ 4    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Out 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.

08.12.2024 22:08 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
let-else - Rust By Example Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries.

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...

08.12.2024 22:06 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Preview
Simplify if-let-Some-else-None using question mark operator ยท Issue #13626 ยท rust-lang/rust-clippy Consider the code below. pub fn f(x: Option<u32>) -> Option<u32> { if let Some(x) = x { dbg!(x); Some(x * 2) } else { None } } Standard Clippy produces no warning. More exhaustive options suggest c...

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...

08.12.2024 22:05 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

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    ๐Ÿ“Œ 0

If 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    ๐Ÿ“Œ 0

Don'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    ๐Ÿ“Œ 0
Introduction - Learning Rust With Entirely Too Many Linked Lists Learning Rust With Entirely Too Many Linked Lists

rust-unofficial.github.io/too-many-lis... ;-)

07.12.2024 11:10 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 2    ๐Ÿ“Œ 0

I 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!

07.12.2024 02:47 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

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    ๐Ÿ“Œ 0

You 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    ๐Ÿ“Œ 0

I 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    ๐Ÿ“Œ 0

Just use HTML for both the backend and the frontend

04.12.2024 20:25 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Does that include rust-analyzer? If so, that sounds high!

04.12.2024 20:23 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Oh, right, I missed that the quoting post was also from the other place!

04.12.2024 07:35 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I 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    ๐Ÿ“Œ 0

Out of curiosity, what are you using nightly for?

04.12.2024 07:32 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

I'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!

04.12.2024 07:31 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
You can move !Unpin - Quentin Santos Although I am now mostly comfortable with Rust, some concepts still elude me. One of them is the exact meaning of Unpin. The documentation says: The documentation of Unpin says: Types that do not requ...

Did you know that #RustLang lets you move !Unpin values?

04.12.2024 06:51 โ€” ๐Ÿ‘ 8    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

It sill hallucinated a typo, but it did pretty well; much better than previous versions.

04.12.2024 06:46 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Another one:

> "Box::heap" in "like you would do with Box::heap" should likely be "Box::pin."

04.12.2024 06:46 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

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    ๐Ÿ“Œ 0

Checking typos with #ChatGPT 4o feels a bit magical:

> "Poll::Read(()),"should be "Poll::Ready(())."

04.12.2024 06:44 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 2    ๐Ÿ“Œ 0

@qsantos.fr is following 19 prominent accounts