Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Convert another instance of Into impl to From in the macros #8986

Merged
2 commits merged into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions frame/support/procedural/src/construct_runtime/expand/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ pub fn expand_outer_origin(
}
}

impl Into<#scrate::sp_std::result::Result<#system_path::Origin<#runtime>, Origin>> for Origin {
impl From<Origin> for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, Origin> {
/// NOTE: converting to pallet origin loses the origin filter information.
fn into(self) -> #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, Self> {
if let OriginCaller::system(l) = self.caller {
fn from(val: Origin) -> Self {
if let OriginCaller::system(l) = val.caller {
Ok(l)
} else {
Err(self)
Err(val)
}
}
}
Expand Down Expand Up @@ -314,13 +314,13 @@ fn expand_origin_pallet_conversions(
}
}

impl Into<#scrate::sp_std::result::Result<#pallet_origin, Origin>> for Origin {
impl From<Origin> for #scrate::sp_std::result::Result<#pallet_origin, Origin> {
/// NOTE: converting to pallet origin loses the origin filter information.
fn into(self) -> #scrate::sp_std::result::Result<#pallet_origin, Self> {
if let OriginCaller::#variant(l) = self.caller {
fn from(val: Origin) -> Self {
if let OriginCaller::#variant(l) = val.caller {
Ok(l)
} else {
Err(self)
Err(val)
}
}
}
Expand Down
16 changes: 6 additions & 10 deletions frame/support/src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,17 @@ macro_rules! impl_outer_origin {
x.into()
}
}
impl Into<
$crate::sp_std::result::Result<
impl From<$name> for $crate::sp_std::result::Result<
$module::Origin < $( $generic )? $(, $module::$generic_instance )? >,
$name,
>>
for $name {
>
{
/// NOTE: converting to pallet origin loses the origin filter information.
fn into(self) -> $crate::sp_std::result::Result<
$module::Origin < $( $generic )? $(, $module::$generic_instance )? >,
Self,
> {
if let $caller_name::[< $module $( _ $generic_instance )? >](l) = self.caller {
fn from(val: $name) -> Self {
if let $caller_name::[< $module $( _ $generic_instance )? >](l) = val.caller {
Ok(l)
} else {
Err(self)
Err(val)
}
}
}
Expand Down