Comments (6)
I think the respective lines should use ref
so that the branch does not take ownership of the event:
SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(mdns::Event::Discovered(ref list))) => {...}
SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(mdns::Event::Expired(ref list))) => {...}
SwarmEvent::Behaviour(MyBehaviourEvent::Gossipsub(gossipsub::Event::Message {
propagation_source: ref peer_id,
message_id: ref id,
ref message,
})) => ...
from rust-libp2p.
That indeed fixes the issue.
from rust-libp2p.
The examples are compiled in CI so I am surprised that they would contain compile errors. Are you running them from within the workspace? Did you copy them to a new project?
See https://github.com/libp2p/rust-libp2p/actions/runs/7463218376/job/20307376998#step:6:756 for the latest successful build of the example in CI.
What version of Rust are you using? Can you paste the output of cargo check --package chat-example
after checking out latest master?
from rust-libp2p.
I'll close this for now because it works in CI.
from rust-libp2p.
@thomaseizinger, I can confirm that Rust 1.75.0
works both with and without ref
. It seems that some versions of the borrow checker might not allow the direct use of the event in match cases.
Therefore, the example doesn't need to change if it's only targeting the current stable rust. However, if there are issues with a particular borrow checker, adding ref
could serve as a workaround for the error.
from rust-libp2p.
Did you use edition 2021? I am pretty sure that this also works for Rust < 1.75 but there may have been changes across the editions.
Anyway, glad it is resolved!
from rust-libp2p.
Related Issues (20)
- Refactor file-sharing example to use tokio instead of async-std
- `Gossipsub`'s substreams keep all connections alive after `idle_connection_timeout`
- mergify continously approving approved pull requests HOT 6
- WebRTC connection doesn't close after timeout HOT 2
- Promote common dependencies to workspace level
- file-sharing works only on local interface HOT 1
- kad: FIND_NODE not conform to specs HOT 9
- Improve request/response documentation HOT 4
- Compilation on docs.rs is failing
- mdns tokio timer panics HOT 2
- Signature verification fails on handshake if 1024 bit RSA key is used HOT 2
- relay: panics due to unimplemented time in wasm HOT 2
- kad: consume `FromSwarm::NewExternalAddrOfPeer` HOT 14
- Reduce `NewExternalAddrCandidate` reports from `identify`
- kad: make `automatic_bootstrap_interval` publicly configurable
- request-response: Inconsistent documentation.
- request-response: Document request/response max sizes HOT 4
- Active streams affect `yamux::connection::rtt` HOT 10
- rendezvous: Example "discovering with identify" doesn't work HOT 4
- kad: make bucket size configurable HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-libp2p.