Skip to content

Commit

Permalink
clippy, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Mar 30, 2021
1 parent 564d909 commit 33f1c0b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions examples/nested_list/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ where
}
}

impl Into<Html> for ListVariant {
fn into(self) -> Html {
match self.props {
impl From<ListVariant> for Html {
fn from(variant: ListVariant) -> Html {
match variant.props {
Variants::Header(props) => {
VComp::new::<ListHeader>(props, NodeRef::default(), None).into()
}
Expand Down
7 changes: 4 additions & 3 deletions packages/yew-dsl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ impl<COMP: Component> BoxedVNodeProducer<COMP> {
}
}

impl<COMP: Component> Into<VNode> for BoxedVNodeProducer<COMP> {
fn into(self) -> VNode {
self.build()
#[allow(clippy::from_over_into)]
impl<COMP: Component> From<BoxedVNodeProducer<COMP>> for VNode {
fn from(value: BoxedVNodeProducer<COMP>) -> VNode {
value.build()
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/yew-macro/src/props/prop_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ impl Parse for PropValue {
}
}

impl Into<Prop> for PropValue {
fn into(self) -> Prop {
let Self {
impl From<PropValue> for Prop {
fn from(prop_value: PropValue) -> Prop {
let PropValue {
label,
colon_token,
value,
} = self;
} = prop_value;
Prop {
label,
question_mark: None,
Expand Down
19 changes: 8 additions & 11 deletions packages/yew-router/src/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SW> = $crate::router::Router<$StateT, SW>;

}
}
};
}
18 changes: 9 additions & 9 deletions packages/yew-services/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,39 @@ pub struct FetchOptions {
pub integrity: Option<String>,
}

impl Into<RequestInit> for FetchOptions {
fn into(self) -> RequestInit {
impl From<FetchOptions> 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"),
Referrer::Empty => init.referrer(""),
};
}

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);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/yew/src/format/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/yew/src/format/nothing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use anyhow::bail;
#[derive(Debug)]
pub struct Nothing;

#[allow(clippy::from_over_into)]
impl Into<Text> for Nothing {
fn into(self) -> Text {
bail!("nothing")
Expand All @@ -19,6 +20,7 @@ impl From<Text> for Nothing {
}
}

#[allow(clippy::from_over_into)]
impl Into<Binary> for Nothing {
fn into(self) -> Binary {
bail!("nothing")
Expand Down

0 comments on commit 33f1c0b

Please sign in to comment.