| 1 |
# Function Overloads |
| 2 |
|
| 3 |
Many Web APIs are overloaded to take different types of arguments or to skip |
| 4 |
arguments completely. `web-sys` contains multiple bindings for these functions |
| 5 |
that each specialize to a particular overload and set of argument types. |
| 6 |
|
| 7 |
For example, [the `fetch` API][mdn-fetch] can be given a URL string, or a |
| 8 |
`Request` object, and it might also optionally be given a `RequestInit` options |
| 9 |
object. Therefore, we end up with these `web-sys` functions that all bind to the |
| 10 |
`window.fetch` function: |
| 11 |
|
| 12 |
* [`Window::fetch_with_str`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Window.html#method.fetch_with_str) |
| 13 |
* [`Window::fetch_with_request`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Window.html#method.fetch_with_request) |
| 14 |
* [`Window::fetch_with_str_and_init`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Window.html#method.fetch_with_str_and_init) |
| 15 |
* [`Window::fetch_with_request_and_init`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Window.html#method.fetch_with_request_and_init) |
| 16 |
|
| 17 |
Note that different overloads can use different interfaces, and therefore can |
| 18 |
require different sets of cargo features to be enabled. |
| 19 |
|
| 20 |
[mdn-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch |