Progrider

Programming discussion

Posts by tomasz

12 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 #14

Coming back to say a month later I am using Rust at work for one small service. I still use indices. See also the thread on tokio mutex, I found new way to confuse myself.


by tomasz
General · post #5

For me it explains the compiler errors quite well. And also sometimes confidently wrong. I still ask here when it's important.


by tomasz
Help · post #5

Works. Each new error teaches me that the thing I was doing was bad. It is like having strict teacher again.


by tomasz
Help · post #3

Why the block? Why not drop(g) before await?


by tomasz
Help · post #1

Hello again. Small service, I have shared state in Arc<std::sync::Mutex<...>>. let mut g = state.lock().unwrap(); g.count += 1; do_something().await; tokio::spawn gives: future cannot be sent between …


by tomasz
General · post #5

I will wait. One difficult language is enough for now.


by tomasz
General · post #9

Pascal in school. We made program for the school library, to track who has which book. Librarian used it three years until the computer died. I think nobody made backup.


by tomasz
Help · post #12

Oh. That was a bug I had and didn't know. Thank you.


by tomasz
Help · post #10

It works. There is also split_at_mut in documentation, is that better?


by tomasz
Help · post #6

Next problem then. My real code is a list of particles, and each one should look at its neighbours and change itself. for p in particles.iter_mut() { for q in particles.iter() { ... } } Same error of …


by tomasz
Help · post #4

OK this makes sense. But if I swap the last two lines it compiles. So the borrow ends at the last use and not at end of the block?


by tomasz
Help · post #1

I learn Rust since two weeks. This does not compile: let mut v = vec![1, 2, 3]; let first = &v[0]; v.push(4); println!("{}", first); error[E0502]: cannot borrow `v` as mutable because it is also borro…


by tomasz
All times shown in UTC.2 topics, 10 replies