Skip to content

Commit 321291f

Browse files
committed
refactor(credential): Pull out alias for BoxError
1 parent 8de4ecb commit 321291f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

credential/cargo-credential/src/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::error::Error as StdError;
22

33
use serde::{Deserialize, Serialize};
44

5+
type BoxError = Box<dyn StdError + Sync + Send>;
6+
57
/// Credential provider error type.
68
///
79
/// `UrlNotSupported` and `NotFound` errors both cause Cargo
@@ -29,7 +31,7 @@ pub enum Error {
2931
/// The provider failed to perform the operation. Other
3032
/// providers will not be attempted
3133
#[serde(with = "error_serialize")]
32-
Other(Box<dyn StdError + Sync + Send>),
34+
Other(BoxError),
3335

3436
/// A new variant was added to this enum since Cargo was built
3537
#[serde(other)]
@@ -123,12 +125,10 @@ mod error_serialize {
123125

124126
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serializer};
125127

126-
use crate::error::StringTypedError;
128+
use super::BoxError;
129+
use super::StringTypedError;
127130

128-
pub fn serialize<S>(
129-
e: &Box<dyn StdError + Send + Sync>,
130-
serializer: S,
131-
) -> Result<S::Ok, S::Error>
131+
pub fn serialize<S>(e: &BoxError, serializer: S) -> Result<S::Ok, S::Error>
132132
where
133133
S: Serializer,
134134
{
@@ -146,7 +146,7 @@ mod error_serialize {
146146
state.end()
147147
}
148148

149-
pub fn deserialize<'de, D>(deserializer: D) -> Result<Box<dyn StdError + Sync + Send>, D::Error>
149+
pub fn deserialize<'de, D>(deserializer: D) -> Result<BoxError, D::Error>
150150
where
151151
D: Deserializer<'de>,
152152
{

0 commit comments

Comments
 (0)