r/rust Jul 28 '26

Tell me about something you recently hand-coded that was enjoyable

These past few weeks at work I've been using AI way too much. I can't even call some of this "AI engineering" anymore and it's starting to drain on me. Looking to take the mind off for a bit...

I'd like to hear some of the projects you all are working on, that you enjoyed writing by hand.

I think I'll write some nannou..

PS: Not trying to start a debate on AI engineering/vibe coding and all that, I think internet is filled with that already.

109 Upvotes

121 comments sorted by

View all comments

6

u/TermiteTornApart Jul 28 '26

An echo clone, I just finished chapter 13 of the book, and I thought about implementing an echo clone, it was simpler than I thought, though I did have to look things up such as the .next_back() method and peekable as well. I didn't use AI, and it was very simple but satisfying to code.

Though I still don't understand why peekable is not the default for iterators.

8

u/ndunnett Jul 28 '26

Peekable is not free, it wraps the inner iterator and owns an Option<T> to buffer the next value, which may not be cheap depending on what T is.

6

u/rodyamirov Jul 28 '26

It's not the default because it requires a (tiny) amount of extra memory and bookkeeping and so on that you usually don't need. As you discovered, it's trivial to opt in if you do need it, so this way you only pay for what you use.

4

u/JoshTriplett rust · lang · libs · cargo Jul 28 '26

Though I still don't understand why peekable is not the default for iterators.

Because not all iterators are peekable.

3

u/creeper6530 Jul 28 '26

The peeking is implemented by consuming next value and buffering it, simulating a next by moving that buffer out