From 18aef02e87db5a2720eb2d08e8940bc3babd066c Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Thu, 10 Mar 2022 17:02:58 +0800 Subject: [PATCH] sc-finality-grandpa: use the #[from] attriute to remove boilerplate code (#11003) Signed-off-by: koushiro --- substrate/client/finality-grandpa/src/lib.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/substrate/client/finality-grandpa/src/lib.rs b/substrate/client/finality-grandpa/src/lib.rs index 8316e56b5b..fef1628638 100644 --- a/substrate/client/finality-grandpa/src/lib.rs +++ b/substrate/client/finality-grandpa/src/lib.rs @@ -279,7 +279,7 @@ impl Config { pub enum Error { /// An error within grandpa. #[error("grandpa error: {0}")] - Grandpa(GrandpaError), + Grandpa(#[from] GrandpaError), /// A network error. #[error("network error: {0}")] @@ -291,7 +291,7 @@ pub enum Error { /// Could not complete a round on disk. #[error("could not complete a round on disk: {0}")] - Client(ClientError), + Client(#[from] ClientError), /// Could not sign outgoing message #[error("could not sign outgoing message: {0}")] @@ -310,18 +310,6 @@ pub enum Error { RuntimeApi(sp_api::ApiError), } -impl From for Error { - fn from(e: GrandpaError) -> Self { - Error::Grandpa(e) - } -} - -impl From for Error { - fn from(e: ClientError) -> Self { - Error::Client(e) - } -} - /// Something which can determine if a block is known. pub(crate) trait BlockStatus { /// Return `Ok(Some(number))` or `Ok(None)` depending on whether the block