From b7dffac93176a4377b279f7f1ca4d1e82d88b996 Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 6 Jan 2023 02:03:18 +0900 Subject: [PATCH] chore(types): Refactor ErrorDetails constructor (#1218) --- tonic-types/src/richer_error/error_details/mod.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tonic-types/src/richer_error/error_details/mod.rs b/tonic-types/src/richer_error/error_details/mod.rs index 4a0913b..4615ca7 100644 --- a/tonic-types/src/richer_error/error_details/mod.rs +++ b/tonic-types/src/richer_error/error_details/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod vec; /// Used when extracting error details from `tonic::Status`, and when /// creating a `tonic::Status` with error details. #[non_exhaustive] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct ErrorDetails { /// This field stores [`RetryInfo`] data, if any. pub(crate) retry_info: Option, @@ -37,12 +37,7 @@ impl ErrorDetails { /// let err_details = ErrorDetails::new(); /// ``` pub fn new() -> Self { - ErrorDetails { - retry_info: None, - debug_info: None, - quota_failure: None, - bad_request: None, - } + Self::default() } /// Generates an [`ErrorDetails`] struct with [`RetryInfo`] details and @@ -370,9 +365,3 @@ impl ErrorDetails { false } } - -impl Default for ErrorDetails { - fn default() -> Self { - Self::new() - } -}