I have a struct that looks like this:
pub struct Game {
/// A HashSet with the players waiting to play as account strings.
lobby: HashSet<String>,
/// capacity determines how many people a match contains.
capacity: u8,
/// A vector of ongoing matches.
matches: Vec<Match>,
/// HashSet indicating for each player which match they are in.
players: HashMap<String, usize>,
}
I realised that this won't work because if there are 3 matches (0, 1, 2) and I remove 1 because it ends, the players that used to point at 2 will be pointing outside the vector or to an incorrect match.
So I thought the obvious solution was to use a reference to the match: players: HashMap<String, &Match>. But this makes lifetimes very complicated.
What's a good way to deal with a case like these where data are interrelated in the same struct?
Hi there,
I'm trying to do some native windows rust programming. I'm using native-windows-gui and native-windows-derive to do it, but if I try to mix that with tokio, I get the following:
No entry point found error for GetWindowSubclass. On console, I get:
error: process didn't exit successfully: `C:\source\myprojectanem\target\debug\myprojectname.exe` (exit code: 0xc0000139, STATUS_ENTRYPOINT_NOT_FOUND)
If I change
#[tokio::main]
async fn main() {
to:
fn main() {
The problem goes away, but obviously I can't use tokio then.
Any clue what the problem is and how to fix it?
Hi there,
I'm working on a bot to do social games on the fedi, and using the mastodon-async crate for communicating with the ActivityPub server in question. At the moment I'm using tokio mt as a runtime, though I'm new at async so if you think I shouldn't let me know.
The pattern I want to implement is the following:
What I'm not very clear is how to keep this list to assure that sequence will be respected. I.a., if two play messages come reasonably quick together, I want one to be processed, then entered on the list, or get the match to start; then the other to get processed.
My current thoughts:
Any thoughts on what the reasonable thing to do is here? I'm very new to async and while I realise there's probably lots of ways to do this, they're not all equally ergonomic and I want to avoid myself future pain.
https://catalyst-journal.com/2022/09/post-work-socialism
Post-work socialism claims to emancipate us from all cultural and economic pressure to work. But post-work utopias illicitly presuppose the very labor they claim to free us from. Shared-labor socialism offers a better vision of freedom, by facing head-on the problem of necessary labor.
@modulus
@lemmy.ml