Skip to content

Commit d7336e8

Browse files
committed
clippy, fmt
1 parent 564d909 commit d7336e8

File tree

8 files changed

+38
-39
lines changed

8 files changed

+38
-39
lines changed

examples/nested_list/src/list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ where
4040
}
4141
}
4242

43-
impl Into<Html> for ListVariant {
44-
fn into(self) -> Html {
45-
match self.props {
43+
impl From<ListVariant> for Html {
44+
fn from(variant: ListVariant) -> Html {
45+
match variant.props {
4646
Variants::Header(props) => {
4747
VComp::new::<ListHeader>(props, NodeRef::default(), None).into()
4848
}

packages/yew-dsl/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl<COMP: Component> BoxedVNodeProducer<COMP> {
3737
}
3838
}
3939

40-
impl<COMP: Component> Into<VNode> for BoxedVNodeProducer<COMP> {
41-
fn into(self) -> VNode {
42-
self.build()
40+
impl<COMP: Component> From<BoxedVNodeProducer<COMP>> for VNode {
41+
fn from(value: BoxedVNodeProducer<COMP>) -> VNode {
42+
value.build()
4343
}
4444
}
4545

packages/yew-macro/src/props/prop_macro.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ impl Parse for PropValue {
6464
}
6565
}
6666

67-
impl Into<Prop> for PropValue {
68-
fn into(self) -> Prop {
69-
let Self {
67+
impl From<PropValue> for Prop {
68+
fn from(prop_value: PropValue) -> Prop {
69+
let PropValue {
7070
label,
7171
colon_token,
7272
value,
73-
} = self;
73+
} = prop_value;
7474
Prop {
7575
label,
7676
question_mark: None,

packages/yew-router/src/alias.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,52 +37,49 @@ macro_rules! define_router_state {
3737
#[doc = ">](route_service/struct.RouteService.html)."]
3838
pub type RouteService = $crate::service::RouteService<$StateT>;
3939

40-
#[cfg(feature="agent")]
40+
#[cfg(feature = "agent")]
4141
#[doc = "Alias to [RouteAgent<"]
4242
#[doc = $StateName]
4343
#[doc = ">](agent/struct.RouteAgent.html)."]
4444
pub type RouteAgent = $crate::agent::RouteAgent<$StateT>;
4545

46-
#[cfg(feature="agent")]
46+
#[cfg(feature = "agent")]
4747
#[doc = "Alias to [RouteAgentBridge<"]
4848
#[doc = $StateName]
4949
#[doc = ">](agent/bridge/struct.RouteAgentBridge.html)`."]
5050
pub type RouteAgentBridge = $crate::agent::RouteAgentBridge<$StateT>;
5151

52-
#[cfg(feature="agent")]
52+
#[cfg(feature = "agent")]
5353
#[doc = "Alias to [RouteAgentDispatcher<"]
5454
#[doc = $StateName]
5555
#[doc = ">](agent/struct.RouteAgentDispatcher.html)`."]
5656
pub type RouteAgentDispatcher = $crate::agent::RouteAgentDispatcher<$StateT>;
5757

58-
5958
#[allow(deprecated)]
6059
#[deprecated(note = "Has been renamed to RouterAnchor")]
61-
#[cfg(feature="components")]
60+
#[cfg(feature = "components")]
6261
#[doc = "Alias to [RouterLink<"]
6362
#[doc = $StateName]
6463
#[doc = ">](components/struct.RouterLink.html)`."]
6564
pub type RouterLink = $crate::components::RouterLink<$StateT>;
6665

67-
68-
#[cfg(feature="components")]
66+
#[cfg(feature = "components")]
6967
#[doc = "Alias to [RouterAnchor<"]
7068
#[doc = $StateName]
7169
#[doc = ">](components/struct.RouterAnchor.html)`."]
7270
pub type RouterAnchor = $crate::components::RouterAnchor<$StateT>;
7371

74-
#[cfg(feature="components")]
72+
#[cfg(feature = "components")]
7573
#[doc = "Alias to [RouterButton<"]
7674
#[doc = $StateName]
7775
#[doc = ">](components/struct.RouterButton.html)`."]
7876
pub type RouterButton = $crate::components::RouterButton<$StateT>;
7977

80-
#[cfg(feature="router")]
78+
#[cfg(feature = "router")]
8179
#[doc = "Alias to [Router<"]
8280
#[doc = $StateName]
8381
#[doc = ">](router/router/struct.Router.html)."]
8482
pub type Router<SW> = $crate::router::Router<$StateT, SW>;
85-
8683
}
87-
}
84+
};
8885
}

packages/yew-services/src/callback_test_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ impl<T> Default for CallbackFuture<T> {
3535
}
3636
}
3737

38-
impl<T: 'static> Into<Callback<T>> for CallbackFuture<T> {
39-
fn into(self) -> Callback<T> {
40-
Callback::from(move |r| self.finish(r))
38+
impl<T: 'static> From<CallbackFuture<T>> for Callback<T> {
39+
fn from(f: CallbackFuture<T>) -> Self {
40+
Callback::from(move |r| f.finish(r))
4141
}
4242
}
4343

packages/yew-services/src/fetch.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,39 +74,39 @@ pub struct FetchOptions {
7474
pub integrity: Option<String>,
7575
}
7676

77-
impl Into<RequestInit> for FetchOptions {
78-
fn into(self) -> RequestInit {
77+
impl From<FetchOptions> for RequestInit {
78+
fn from(fetch_options: FetchOptions) -> RequestInit {
7979
let mut init = RequestInit::new();
8080

81-
if let Some(cache) = self.cache {
81+
if let Some(cache) = fetch_options.cache {
8282
init.cache(cache);
8383
}
8484

85-
if let Some(credentials) = self.credentials {
85+
if let Some(credentials) = fetch_options.credentials {
8686
init.credentials(credentials);
8787
}
8888

89-
if let Some(redirect) = self.redirect {
89+
if let Some(redirect) = fetch_options.redirect {
9090
init.redirect(redirect);
9191
}
9292

93-
if let Some(mode) = self.mode {
93+
if let Some(mode) = fetch_options.mode {
9494
init.mode(mode);
9595
}
9696

97-
if let Some(referrer) = self.referrer {
97+
if let Some(referrer) = fetch_options.referrer {
9898
match referrer {
9999
Referrer::SameOriginUrl(referrer) => init.referrer(&referrer),
100100
Referrer::AboutClient => init.referrer("about:client"),
101101
Referrer::Empty => init.referrer(""),
102102
};
103103
}
104104

105-
if let Some(referrer_policy) = self.referrer_policy {
105+
if let Some(referrer_policy) = fetch_options.referrer_policy {
106106
init.referrer_policy(referrer_policy);
107107
}
108108

109-
if let Some(integrity) = self.integrity {
109+
if let Some(integrity) = fetch_options.integrity {
110110
init.integrity(&integrity);
111111
}
112112

packages/yew/src/format/macros.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#[macro_export]
2121
macro_rules! text_format {
2222
($type:ident based on $format:ident) => {
23-
impl<'a, T> Into<$crate::format::Text> for $type<&'a T>
23+
impl<'a, T> From<$type<&'a T>> for $crate::format::Text
2424
where
2525
T: ::serde::Serialize,
2626
{
27-
fn into(self) -> $crate::format::Text {
28-
$format::to_string(&self.0).map_err(::anyhow::Error::from)
27+
fn from(value: $type<&'a T>) -> $crate::format::Text {
28+
$format::to_string(&value.0).map_err(::anyhow::Error::from)
2929
}
3030
}
3131

@@ -108,12 +108,12 @@ macro_rules! binary_format {
108108
binary_format!($type, $format::to_vec, $format::from_slice);
109109
};
110110
($type:ident, $into:path, $from:path) => {
111-
impl<'a, T> Into<$crate::format::Binary> for $type<&'a T>
111+
impl<'a, T> From<$type<&'a T>> for $crate::format::Binary
112112
where
113113
T: ::serde::Serialize,
114114
{
115-
fn into(self) -> $crate::format::Binary {
116-
$into(&self.0).map_err(::anyhow::Error::from)
115+
fn from(value: $type<&'a T>) -> $crate::format::Binary {
116+
$into(&value.0).map_err(::anyhow::Error::from)
117117
}
118118
}
119119

packages/yew/src/format/nothing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use anyhow::bail;
77
#[derive(Debug)]
88
pub struct Nothing;
99

10+
#[allow(clippy::from_over_into)]
1011
impl Into<Text> for Nothing {
1112
fn into(self) -> Text {
1213
bail!("nothing")
@@ -19,6 +20,7 @@ impl From<Text> for Nothing {
1920
}
2021
}
2122

23+
#[allow(clippy::from_over_into)]
2224
impl Into<Binary> for Nothing {
2325
fn into(self) -> Binary {
2426
bail!("nothing")

0 commit comments

Comments
 (0)