Skip to content

Conversation

cibyr
Copy link
Contributor

@cibyr cibyr commented Jul 16, 2025

The missing use<> trait bounds confused the hell out of me trying to use some of the example code in a project using edition = "2024" so I thought I'd try and save others from the same fate.

For the sake of anyone searching, the error messages look like:

   Compiling browser-echo v0.1.0 (/home/cibyr/src/iroh-examples/browser-echo)
error[E0521]: borrowed data escapes outside of method
  --> src/wasm.rs:53:12
   |
47 |     pub fn connect(&self, node_id: String, payload: String) -> Result<JsReadableStream, JsError> {
   |                    -----
   |                    |
   |                    `self` is a reference that is only valid in the method body
   |                    let's call the lifetime of this reference `'1`
...
53 |         Ok(into_js_readable_stream(stream))
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |            |
   |            `self` escapes the method body here
   |            argument requires that `'1` must outlive `'static`

For more information about this error, try `rustc --explain E0521`.

Which didn't help me figure out that this was due to the changed lifetime capture rules in the 2024 edition, as applied to EchoNode::connect().

Previous lockfile failed to parse due to duplicated packages.
@n0bot n0bot bot added this to iroh Jul 16, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Jul 16, 2025
@b5 b5 requested a review from matheus23 July 16, 2025 10:48
Copy link
Member

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you this is very helpful!

cibyr added 2 commits July 16, 2025 19:29
`cargo fix --edition` did all the work except for changing the spelling
of "crate_type" to "crate-type".
Copy link
Member

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff, TYVM!

@matheus23 matheus23 merged commit fca278c into n0-computer:main Jul 17, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants