Advertisement Β· 728 Γ— 90

Posts by Quentin

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

1 year ago 0 0 0 0
Why is it so hard to buy things that work well?

danluu.com/nothing-works/

1 year ago 0 0 0 0

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

1 year ago 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.

1 year ago 1 0 1 0

Mostly in Iterator::next so far

1 year ago 1 0 0 0

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

1 year ago 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.

1 year ago 4 0 0 0
Advertisement

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.

1 year ago 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...

1 year ago 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...

1 year ago 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.

1 year ago 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.

1 year ago 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.

1 year ago 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... ;-)

1 year ago 1 0 2 0
Advertisement

I think that experiencing C++ can actually help understand some of the design decisions of Rust, so not a bad idea all in all.

1 year ago 2 0 0 0

> is there a such thing as learning to many languages at once?

No, as long as it is Rust!

1 year ago 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.

1 year ago 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.

1 year ago 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.

1 year ago 0 0 0 0

Just use HTML for both the backend and the frontend

1 year ago 0 0 0 0

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

1 year ago 0 0 0 0
Advertisement

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

1 year ago 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!

1 year ago 1 0 1 0

Out of curiosity, what are you using nightly for?

1 year ago 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!

1 year ago 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?

1 year ago 8 1 0 0

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

1 year ago 0 0 0 0

Another one:

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

1 year ago 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.

1 year ago 0 0 1 0

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

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

1 year ago 0 0 2 0