Giter Site home page Giter Site logo

Comments (6)

gnattu avatar gnattu commented on May 30, 2024

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.

ealione avatar ealione commented on May 30, 2024

That indeed fixes the issue.

from rust-libp2p.

thomaseizinger avatar thomaseizinger commented on May 30, 2024

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.

thomaseizinger avatar thomaseizinger commented on May 30, 2024

I'll close this for now because it works in CI.

from rust-libp2p.

gnattu avatar gnattu commented on May 30, 2024

@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.

thomaseizinger avatar thomaseizinger commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.