diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 43612bb120f..15e8d96e540 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -198,7 +198,7 @@ jobs: strategy: matrix: toolchain: - - 1.45.0 # MSRV + - 1.51.0 # min version with const generics - stable - nightly diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c568dce42a4..214248d24ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,9 +68,10 @@ Alternatively, you can set the `ECHO_SERVER_URL` environment variable to the URL When adding or updating tests, please make sure to update the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/packages/yew-macro/tests/macro) for the `html!` macro. These files ensure that macro compilation errors are correct and easy to understand. -These errors can change with each release of the compiler so they should be generated with the MSRV (currently 1.45). +These errors can change with each release of the compiler so they should be generated with the Rust version 1.51 +(because some tests make use of const generics which were stabilized in that version). -To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo +1.45.2 test` in the `yew-macro` directory. +To update or generate a new `stderr` file you can run `cargo make test-overwrite` in the `yew-macro` directory. ## Linting diff --git a/examples/nested_list/src/list.rs b/examples/nested_list/src/list.rs index 570fdf6a0bc..b6f0ea41d8d 100644 --- a/examples/nested_list/src/list.rs +++ b/examples/nested_list/src/list.rs @@ -40,9 +40,9 @@ where } } -impl Into for ListVariant { - fn into(self) -> Html { - match self.props { +impl From for Html { + fn from(variant: ListVariant) -> Html { + match variant.props { Variants::Header(props) => { VComp::new::(props, NodeRef::default(), None).into() } diff --git a/packages/yew-dsl/src/lib.rs b/packages/yew-dsl/src/lib.rs index 5e24f792f2f..475085fd98a 100644 --- a/packages/yew-dsl/src/lib.rs +++ b/packages/yew-dsl/src/lib.rs @@ -37,9 +37,9 @@ impl BoxedVNodeProducer { } } -impl Into for BoxedVNodeProducer { - fn into(self) -> VNode { - self.build() +impl From> for VNode { + fn from(value: BoxedVNodeProducer) -> VNode { + value.build() } } diff --git a/packages/yew-functional-macro/Makefile.toml b/packages/yew-functional-macro/Makefile.toml index 2df620e7c5d..a6e497471e1 100644 --- a/packages/yew-functional-macro/Makefile.toml +++ b/packages/yew-functional-macro/Makefile.toml @@ -1,6 +1,6 @@ [tasks.test] clear = true -toolchain = "1.45.2" +toolchain = "1.51" command = "cargo" args = ["test"] diff --git a/packages/yew-functional-macro/tests/function_attr/bad-return-type-fail.stderr b/packages/yew-functional-macro/tests/function_attr/bad-return-type-fail.stderr index b25fe5a3eef..283e09594dc 100644 --- a/packages/yew-functional-macro/tests/function_attr/bad-return-type-fail.stderr +++ b/packages/yew-functional-macro/tests/function_attr/bad-return-type-fail.stderr @@ -8,6 +8,6 @@ error[E0308]: mismatched types --> $DIR/bad-return-type-fail.rs:14:5 | 13 | fn comp(_props: &Props) -> u32 { - | --- expected `yew::virtual_dom::vnode::VNode` because of return type + | --- expected `VNode` because of return type 14 | 1 - | ^ expected enum `yew::virtual_dom::vnode::VNode`, found integer + | ^ expected enum `VNode`, found integer diff --git a/packages/yew-functional-macro/tests/function_attr_test.rs b/packages/yew-functional-macro/tests/function_attr_test.rs index 34c7e9db899..9747bc8d82f 100644 --- a/packages/yew-functional-macro/tests/function_attr_test.rs +++ b/packages/yew-functional-macro/tests/function_attr_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.45), test)] +#[rustversion::attr(stable(1.51), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/function_attr/*-pass.rs"); diff --git a/packages/yew-macro/Makefile.toml b/packages/yew-macro/Makefile.toml index 2df620e7c5d..a6e497471e1 100644 --- a/packages/yew-macro/Makefile.toml +++ b/packages/yew-macro/Makefile.toml @@ -1,6 +1,6 @@ [tasks.test] clear = true -toolchain = "1.45.2" +toolchain = "1.51" command = "cargo" args = ["test"] diff --git a/packages/yew-macro/tests/classes_macro/classes-fail.stderr b/packages/yew-macro/tests/classes_macro/classes-fail.stderr index 06ad2357591..df4ac0aac3a 100644 --- a/packages/yew-macro/tests/classes_macro/classes-fail.stderr +++ b/packages/yew-macro/tests/classes_macro/classes-fail.stderr @@ -10,92 +10,95 @@ error: string literals must not contain more than one class (hint: use `"two", " 18 | classes!("one", "two three", "four"); | ^^^^^^^^^^^ -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied +error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> $DIR/classes-fail.rs:4:14 | 4 | classes!(42); - | ^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes` + | ^^ the trait `From<{integer}>` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `{integer}` + = note: required because of the requirements on the impl of `Into` for `{integer}` -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{float}>` is not satisfied +error[E0277]: the trait bound `Classes: From<{float}>` is not satisfied --> $DIR/classes-fail.rs:5:14 | 5 | classes!(42.0); - | ^^^^ the trait `std::convert::From<{float}>` is not implemented for `yew::html::classes::Classes` + | ^^^^ the trait `From<{float}>` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `{float}` + = note: required because of the requirements on the impl of `Into` for `{float}` -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied +error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> $DIR/classes-fail.rs:9:14 | 9 | classes!(vec![42]); - | ^^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes` + | ^^^ the trait `From<{integer}>` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `{integer}` - = note: required because of the requirements on the impl of `std::convert::From>` for `yew::html::classes::Classes` - = note: required because of the requirements on the impl of `std::convert::Into` for `std::vec::Vec<{integer}>` + = note: required because of the requirements on the impl of `Into` for `{integer}` + = note: required because of the requirements on the impl of `From>` for `Classes` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Into` for `std::vec::Vec<{integer}>` -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied +error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> $DIR/classes-fail.rs:13:14 | 13 | classes!(some); - | ^^^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes` + | ^^^^ the trait `From<{integer}>` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `{integer}` - = note: required because of the requirements on the impl of `std::convert::From>` for `yew::html::classes::Classes` - = note: required because of the requirements on the impl of `std::convert::Into` for `std::option::Option<{integer}>` + = note: required because of the requirements on the impl of `Into` for `{integer}` + = note: required because of the requirements on the impl of `From>` for `Classes` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Into` for `Option<{integer}>` -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From` is not satisfied +error[E0277]: the trait bound `Classes: From` is not satisfied --> $DIR/classes-fail.rs:14:14 | 14 | classes!(none); - | ^^^^ the trait `std::convert::From` is not implemented for `yew::html::classes::Classes` + | ^^^^ the trait `From` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `u32` - = note: required because of the requirements on the impl of `std::convert::From>` for `yew::html::classes::Classes` - = note: required because of the requirements on the impl of `std::convert::Into` for `std::option::Option` + = note: required because of the requirements on the impl of `Into` for `u32` + = note: required because of the requirements on the impl of `From>` for `Classes` + = note: 1 redundant requirements hidden + = note: required because of the requirements on the impl of `Into` for `Option` -error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied +error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> $DIR/classes-fail.rs:16:21 | 16 | classes!("one", 42); - | ^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes` + | ^^ the trait `From<{integer}>` is not implemented for `Classes` | = help: the following implementations were found: - > - > - >> - > + > + >> + > + > and 4 others - = note: required because of the requirements on the impl of `std::convert::Into` for `{integer}` + = note: required because of the requirements on the impl of `Into` for `{integer}` diff --git a/packages/yew-macro/tests/classes_macro_test.rs b/packages/yew-macro/tests/classes_macro_test.rs index 9a340d66fa0..ededbf6e042 100644 --- a/packages/yew-macro/tests/classes_macro_test.rs +++ b/packages/yew-macro/tests/classes_macro_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.45), test)] +#[rustversion::attr(stable(1.51), test)] fn classes_macro() { let t = trybuild::TestCases::new(); t.pass("tests/classes_macro/*-pass.rs"); diff --git a/packages/yew-macro/tests/derive_props_test.rs b/packages/yew-macro/tests/derive_props_test.rs index 0855a7c0d56..0f83e8bc4fa 100644 --- a/packages/yew-macro/tests/derive_props_test.rs +++ b/packages/yew-macro/tests/derive_props_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.45), test)] +#[rustversion::attr(stable(1.51), test)] fn derive_props() { let t = trybuild::TestCases::new(); t.pass("tests/derive_props/pass.rs"); diff --git a/packages/yew-macro/tests/html_macro/html-block-fail.stderr b/packages/yew-macro/tests/html_macro/html-block-fail.stderr index 3c4a8d62d25..2a827e00d7b 100644 --- a/packages/yew-macro/tests/html_macro/html-block-fail.stderr +++ b/packages/yew-macro/tests/html_macro/html-block-fail.stderr @@ -6,12 +6,12 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::string::ToString` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode` - = note: required because of the requirements on the impl of `std::convert::Into` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>` - = note: required because of the requirements on the impl of `std::convert::Into>` for `()` - = note: required by `std::convert::Into::into` + = note: required because of the requirements on the impl of `ToString` for `()` + = note: required because of the requirements on the impl of `From<()>` for `VNode` + = note: required because of the requirements on the impl of `Into` for `()` + = note: 2 redundant requirements hidden + = note: required because of the requirements on the impl of `Into>` for `()` + = note: required by `into` error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/html-block-fail.rs:12:16 @@ -21,12 +21,12 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::string::ToString` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode` - = note: required because of the requirements on the impl of `std::convert::Into` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>` - = note: required because of the requirements on the impl of `std::convert::Into>` for `()` - = note: required by `std::convert::Into::into` + = note: required because of the requirements on the impl of `ToString` for `()` + = note: required because of the requirements on the impl of `From<()>` for `VNode` + = note: required because of the requirements on the impl of `Into` for `()` + = note: 2 redundant requirements hidden + = note: required because of the requirements on the impl of `Into>` for `()` + = note: required by `into` error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/html-block-fail.rs:15:17 @@ -37,10 +37,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` ::: $WORKSPACE/packages/yew/src/utils.rs | | T: Into, - | ------- required by this bound in `yew::utils::into_node_iter` + | ------- required by this bound in `into_node_iter` | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::string::ToString` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode` - = note: required because of the requirements on the impl of `std::convert::Into` for `()` + = note: required because of the requirements on the impl of `ToString` for `()` + = note: required because of the requirements on the impl of `From<()>` for `VNode` + = note: required because of the requirements on the impl of `Into` for `()` diff --git a/packages/yew-macro/tests/html_macro/html-node-fail.stderr b/packages/yew-macro/tests/html_macro/html-node-fail.stderr index bcaf64e7d20..dae1f802bfa 100644 --- a/packages/yew-macro/tests/html_macro/html-node-fail.stderr +++ b/packages/yew-macro/tests/html_macro/html-node-fail.stderr @@ -48,9 +48,9 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::string::ToString` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode` - = note: required by `std::convert::From::from` + = note: required because of the requirements on the impl of `ToString` for `()` + = note: required because of the requirements on the impl of `From<()>` for `VNode` + = note: required by `from` error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/html-node-fail.rs:17:9 @@ -60,6 +60,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: required because of the requirements on the impl of `std::string::ToString` for `()` - = note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode` - = note: required by `std::convert::From::from` + = note: required because of the requirements on the impl of `ToString` for `()` + = note: required because of the requirements on the impl of `From<()>` for `VNode` + = note: required by `from` diff --git a/packages/yew-macro/tests/html_macro_test.rs b/packages/yew-macro/tests/html_macro_test.rs index a8aef3d50e0..92dca13b234 100644 --- a/packages/yew-macro/tests/html_macro_test.rs +++ b/packages/yew-macro/tests/html_macro_test.rs @@ -1,7 +1,7 @@ use yew::html; #[allow(dead_code)] -#[rustversion::attr(stable(1.45), test)] +#[rustversion::attr(stable(1.51), test)] fn html_macro() { let t = trybuild::TestCases::new(); diff --git a/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr b/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr index 9af4b6e5901..45d2f67d396 100644 --- a/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr +++ b/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr @@ -1,17 +1,21 @@ -error[E0277]: the trait bound `std::vec::Vec<_>: yew::html::component::properties::Properties` is not satisfied +error[E0277]: the trait bound `std::vec::Vec<_>: yew::Properties` is not satisfied --> $DIR/resolve-prop-fail.rs:38:17 | 38 | yew::props!(Vec<_> {}); - | ^^^ the trait `yew::html::component::properties::Properties` is not implemented for `std::vec::Vec<_>` + | ^^^ the trait `yew::Properties` is not implemented for `std::vec::Vec<_>` + | + = note: required by `builder` -error[E0277]: the trait bound `MyComp: yew::html::component::properties::Properties` is not satisfied +error[E0277]: the trait bound `MyComp: yew::Properties` is not satisfied --> $DIR/resolve-prop-fail.rs:39:17 | 39 | yew::props!(MyComp {}); - | ^^^^^^ the trait `yew::html::component::properties::Properties` is not implemented for `MyComp` + | ^^^^^^ the trait `yew::Properties` is not implemented for `MyComp` + | + = note: required by `builder` -error[E0277]: the trait bound `MyNotAComponent: yew::html::component::Component` is not satisfied +error[E0277]: the trait bound `MyNotAComponent: yew::Component` is not satisfied --> $DIR/resolve-prop-fail.rs:40:17 | 40 | yew::props!(MyNotAComponent::Properties {}); - | ^^^^^^^^^^^^^^^ the trait `yew::html::component::Component` is not implemented for `MyNotAComponent` + | ^^^^^^^^^^^^^^^ the trait `yew::Component` is not implemented for `MyNotAComponent` diff --git a/packages/yew-macro/tests/props_macro_test.rs b/packages/yew-macro/tests/props_macro_test.rs index f0875073753..d4016aacd63 100644 --- a/packages/yew-macro/tests/props_macro_test.rs +++ b/packages/yew-macro/tests/props_macro_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.45), test)] +#[rustversion::attr(stable(1.51), test)] fn props_macro() { let t = trybuild::TestCases::new(); t.pass("tests/props_macro/*-pass.rs"); diff --git a/packages/yew-router/src/alias.rs b/packages/yew-router/src/alias.rs index 6969b6b9aa1..015d8a4ce96 100644 --- a/packages/yew-router/src/alias.rs +++ b/packages/yew-router/src/alias.rs @@ -37,52 +37,49 @@ macro_rules! define_router_state { #[doc = ">](route_service/struct.RouteService.html)."] pub type RouteService = $crate::service::RouteService<$StateT>; - #[cfg(feature="agent")] + #[cfg(feature = "agent")] #[doc = "Alias to [RouteAgent<"] #[doc = $StateName] #[doc = ">](agent/struct.RouteAgent.html)."] pub type RouteAgent = $crate::agent::RouteAgent<$StateT>; - #[cfg(feature="agent")] + #[cfg(feature = "agent")] #[doc = "Alias to [RouteAgentBridge<"] #[doc = $StateName] #[doc = ">](agent/bridge/struct.RouteAgentBridge.html)`."] pub type RouteAgentBridge = $crate::agent::RouteAgentBridge<$StateT>; - #[cfg(feature="agent")] + #[cfg(feature = "agent")] #[doc = "Alias to [RouteAgentDispatcher<"] #[doc = $StateName] #[doc = ">](agent/struct.RouteAgentDispatcher.html)`."] pub type RouteAgentDispatcher = $crate::agent::RouteAgentDispatcher<$StateT>; - #[allow(deprecated)] #[deprecated(note = "Has been renamed to RouterAnchor")] - #[cfg(feature="components")] + #[cfg(feature = "components")] #[doc = "Alias to [RouterLink<"] #[doc = $StateName] #[doc = ">](components/struct.RouterLink.html)`."] pub type RouterLink = $crate::components::RouterLink<$StateT>; - - #[cfg(feature="components")] + #[cfg(feature = "components")] #[doc = "Alias to [RouterAnchor<"] #[doc = $StateName] #[doc = ">](components/struct.RouterAnchor.html)`."] pub type RouterAnchor = $crate::components::RouterAnchor<$StateT>; - #[cfg(feature="components")] + #[cfg(feature = "components")] #[doc = "Alias to [RouterButton<"] #[doc = $StateName] #[doc = ">](components/struct.RouterButton.html)`."] pub type RouterButton = $crate::components::RouterButton<$StateT>; - #[cfg(feature="router")] + #[cfg(feature = "router")] #[doc = "Alias to [Router<"] #[doc = $StateName] #[doc = ">](router/router/struct.Router.html)."] pub type Router = $crate::router::Router<$StateT, SW>; - } - } + }; } diff --git a/packages/yew/src/format/macros.rs b/packages/yew/src/format/macros.rs index b74b524b504..6d335d0eefa 100644 --- a/packages/yew/src/format/macros.rs +++ b/packages/yew/src/format/macros.rs @@ -20,12 +20,12 @@ #[macro_export] macro_rules! text_format { ($type:ident based on $format:ident) => { - impl<'a, T> Into<$crate::format::Text> for $type<&'a T> + impl<'a, T> From<$type<&'a T>> for $crate::format::Text where T: ::serde::Serialize, { - fn into(self) -> $crate::format::Text { - $format::to_string(&self.0).map_err(::anyhow::Error::from) + fn from(value: $type<&'a T>) -> $crate::format::Text { + $format::to_string(&value.0).map_err(::anyhow::Error::from) } } @@ -108,12 +108,12 @@ macro_rules! binary_format { binary_format!($type, $format::to_vec, $format::from_slice); }; ($type:ident, $into:path, $from:path) => { - impl<'a, T> Into<$crate::format::Binary> for $type<&'a T> + impl<'a, T> From<$type<&'a T>> for $crate::format::Binary where T: ::serde::Serialize, { - fn into(self) -> $crate::format::Binary { - $into(&self.0).map_err(::anyhow::Error::from) + fn from(value: $type<&'a T>) -> $crate::format::Binary { + $into(&value.0).map_err(::anyhow::Error::from) } } diff --git a/packages/yew/src/format/nothing.rs b/packages/yew/src/format/nothing.rs index 88bc5fa6069..d65dfa3e3a8 100644 --- a/packages/yew/src/format/nothing.rs +++ b/packages/yew/src/format/nothing.rs @@ -7,6 +7,7 @@ use anyhow::bail; #[derive(Debug)] pub struct Nothing; +#[allow(clippy::from_over_into)] impl Into for Nothing { fn into(self) -> Text { bail!("nothing") @@ -19,6 +20,7 @@ impl From for Nothing { } } +#[allow(clippy::from_over_into)] impl Into for Nothing { fn into(self) -> Binary { bail!("nothing") diff --git a/packages/yew/src/services/fetch/web_sys.rs b/packages/yew/src/services/fetch/web_sys.rs index 6e0252cafc9..1249cbea93a 100644 --- a/packages/yew/src/services/fetch/web_sys.rs +++ b/packages/yew/src/services/fetch/web_sys.rs @@ -75,27 +75,27 @@ pub struct FetchOptions { pub integrity: Option, } -impl Into for FetchOptions { - fn into(self) -> RequestInit { +impl From for RequestInit { + fn from(fetch_options: FetchOptions) -> RequestInit { let mut init = RequestInit::new(); - if let Some(cache) = self.cache { + if let Some(cache) = fetch_options.cache { init.cache(cache); } - if let Some(credentials) = self.credentials { + if let Some(credentials) = fetch_options.credentials { init.credentials(credentials); } - if let Some(redirect) = self.redirect { + if let Some(redirect) = fetch_options.redirect { init.redirect(redirect); } - if let Some(mode) = self.mode { + if let Some(mode) = fetch_options.mode { init.mode(mode); } - if let Some(referrer) = self.referrer { + if let Some(referrer) = fetch_options.referrer { match referrer { Referrer::SameOriginUrl(referrer) => init.referrer(&referrer), Referrer::AboutClient => init.referrer("about:client"), @@ -103,11 +103,11 @@ impl Into for FetchOptions { }; } - if let Some(referrer_policy) = self.referrer_policy { + if let Some(referrer_policy) = fetch_options.referrer_policy { init.referrer_policy(referrer_policy); } - if let Some(integrity) = self.integrity { + if let Some(integrity) = fetch_options.integrity { init.integrity(&integrity); }