Skip to content

Commit

Permalink
readme: update for new bindgen macro (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Feb 29, 2024
1 parent 561aa17 commit 9798f56
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@ file. Example code using this then looks like:
wit_bindgen::generate!({
// the name of the world in the `*.wit` input file
world: "host",

// For all exported worlds, interfaces, and resources, this specifies what
// type they're corresponding to in this module. In this case the `MyHost`
// struct defined below is going to define the exports of the `world`,
// namely the `run` function.
exports: {
world: MyHost,
},
});

// Define a custom type and implement the generated `Guest` trait for it which
Expand All @@ -237,6 +229,10 @@ impl Guest for MyHost {
print("Hello, world!");
}
}

// export! defines that the `MyHost` struct defined below is going to define
// the exports of the `world`, namely the `run` function.
export!(MyHost);
```

By using [`cargo expand`](https://github.com/dtolnay/cargo-expand) or `cargo
Expand Down

0 comments on commit 9798f56

Please sign in to comment.