I would like to make a function that can take either owned value, or a reference that can be cloned into an owned value. This way an owned value can be passed in without extra cloning. It seems I am able to do it with a custom trait specifically for String/&str
, but I couldn’t find anything similar/generic in stdlib. Am this approach inco..
Tag : rust
I would like to make a function that can take either owned value, or a reference that can be cloned into an owned value. This way an owned value can be passed in without extra cloning. It seems I am able to do it with a custom trait specifically for String/&str
, but I couldn’t find anything similar/generic in s..
loop { select! { Ok(Some(line)) = stdin.next_line() => { handle_input(&mut swarm, line.to_string()).await?; } event = swarm.select_next_some() => match event { SwarmEvent::Behaviour(P2PBehaviourEvent::Mdns(mdns::Event::Discovered(list))) => { for (peer_id, _multiaddr) in list { println!(“Discovered a new peer: {peer_id}”); swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id); } }, SwarmEvent::Behaviour(P2PBehaviourEvent::Mdns(mdns::Event::Expired(list))) => { for (peer_id, _multiaddr) in list { println!(“Peer {peer_id} has expired”); swarm.behaviour_mut().gossipsub.remove_explicit_peer(&peer_id); } }, SwarmEvent::Behaviour(P2PBehaviourEvent::Gossipsub(gossipsub::Event::Message { ..
I’ve read the section in the Rust Book on importing crates but I am still missing some..
I want to debug a rust program in ..
Can I write some code to get a lifetime value deref from a none lifetime v..
In other words, if I have defined a type lik..
I have a fairly large Rust application, and, as I was scrolling through it, I realized that I had many clone calls. Is it considered evil or at least not best practice to have many calls of clone? Will it clog up the process? If so, what is the idiomatic method of replacing ..
I have a slightly more complex enum with the same set of actions taken for multiple of the possible options, e.g. somethin..
I have a slightly more complex enum with the same set of actions taken for multiple of the possible options, e.g. somethin..