File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ fn is_critical_json_rpc_error(
105105 SendRequestError :: TransportError ( err) => match err {
106106 RpcCallError :: Http ( e) => {
107107 use reqwest:: StatusCode ;
108- e. status ( ) . map_or ( false , |s| {
108+ e. status ( ) . is_some_and ( |s| {
109109 !matches ! (
110110 s,
111111 StatusCode :: REQUEST_TIMEOUT
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ pub enum SendRequestError {
288288
289289impl SendRequestError {
290290 /// Returns the underlying [`RpcError`] if this is a server error.
291- pub fn as_rpc_error ( & self ) -> Option < & RpcError > {
291+ pub const fn as_rpc_error ( & self ) -> Option < & RpcError > {
292292 match self {
293293 Self :: ServerError ( e) => Some ( e) ,
294294 _ => None ,
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ pub enum RpcCallError {
4545}
4646
4747impl RpcClient {
48- pub fn new ( url : String , client : reqwest:: Client ) -> Self {
48+ pub const fn new ( url : String , client : reqwest:: Client ) -> Self {
4949 Self { client, url }
5050 }
5151
@@ -78,11 +78,13 @@ impl RpcClient {
7878 return Err ( RpcCallError :: Rpc ( error) ) ;
7979 }
8080
81- match response. result {
82- Some ( value) => serde_json:: from_value ( value) . map_err ( RpcCallError :: Deserialize ) ,
83- None => Err ( RpcCallError :: Deserialize ( serde:: de:: Error :: custom (
84- "response has neither result nor error" ,
85- ) ) ) ,
86- }
81+ response. result . map_or_else (
82+ || {
83+ Err ( RpcCallError :: Deserialize ( serde:: de:: Error :: custom (
84+ "response has neither result nor error" ,
85+ ) ) )
86+ } ,
87+ |value| serde_json:: from_value ( value) . map_err ( RpcCallError :: Deserialize ) ,
88+ )
8789 }
8890}
You can’t perform that action at this time.
0 commit comments