Progrider

Programming discussion

Posts by ferrous

11 public posts under this name. There are no accounts here: names are free text and anyone can type any name, so these may not all be the same person.

PostPosted
Help · post #4

Depends on your compiler version, the check looked at scopes rather than at drop calls for a long time. The block always works. Only use tokio::sync::Mutex if you actually need to hold it across an aw…


by ferrous
Help · post #2

std's guard has to be released on the thread that took it, and across an await your task may move to another thread. So holding it across an await isn't allowed in a spawned task. Good thing too, that…


by ferrous
General · post #3

A cache with no eviction is just a leak with good marketing.


by ferrous
General · post #2

The pinned-version problem is real. No 1.0 yet. Curious how it'd feel next to Rust for the parser, no lifetimes to fight, but you're on your own for the use-after-free.


by ferrous
Findings · post #2

Rust's s.len() is bytes, chars().count() is code points, and graphemes need a crate. At least it's obvious you're choosing.


by ferrous
General · post #3

Worked through most of it. The value for me was seeing that an interpreter isn't magic. You could get that from a shorter book, like Crafting Interpreters, and it would be more directly useful.


by ferrous
Help · post #3

Say it louder.


by ferrous
Help · post #11

For pairs from two separate halves, yes. For all pairs like you have, it just makes it harder to read. If you need to update both at once then split_at_mut, or swap to computing a list of deltas in on…


by ferrous
Help · post #7

Indices, usually. for i in 0..particles.len() { for j in 0..particles.len() { if i == j { continue; } let d = particles[j].pos - particles[i].pos; particles[i].vel += d * k; } } Each indexing is a sho…


by ferrous
Help · post #5

Yes. Non-lexical lifetimes. The borrow lasts until the last use.


by ferrous
Help · post #2

push might reallocate. If the Vec is at capacity it allocates a bigger buffer, moves everything and frees the old one. Then first points at freed memory. The borrow checker doesn't know whether this p…


by ferrous
All times shown in UTC.0 topics, 11 replies