diff options
| author | Maiddog <[email protected]> | 2017-08-22 06:27:10 -0500 |
|---|---|---|
| committer | alex <[email protected]> | 2017-08-22 13:27:10 +0200 |
| commit | cb072aab60ac67bc4d52aed3554300c1c5e83081 (patch) | |
| tree | fc00dd5d91b989582e10a93afb4713f1fbd6c88f /src/model/misc.rs | |
| parent | Fix presence updates (diff) | |
| download | serenity-cb072aab60ac67bc4d52aed3554300c1c5e83081.tar.xz serenity-cb072aab60ac67bc4d52aed3554300c1c5e83081.zip | |
Fix tests (#145)
Diffstat (limited to 'src/model/misc.rs')
| -rw-r--r-- | src/model/misc.rs | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/model/misc.rs b/src/model/misc.rs index 8106c40..dee915e 100644 --- a/src/model/misc.rs +++ b/src/model/misc.rs @@ -60,25 +60,23 @@ impl Mentionable for User { #[derive(Debug)] pub enum UserParseError { NotPresentInCache, - InvalidUsername + InvalidUsername, } #[cfg(all(feature = "model", feature = "utils"))] impl fmt::Display for UserParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description()) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description()) } } #[cfg(all(feature = "cache", feature = "utils"))] impl StdError for UserParseError { fn description(&self) -> &str { use self::UserParseError::*; - + match *self { NotPresentInCache => "not present in cache", - InvalidUsername => "invalid username" + InvalidUsername => "invalid username", } } } @@ -108,16 +106,14 @@ pub enum UserIdParseError { #[cfg(all(feature = "model", feature = "utils"))] impl fmt::Display for UserIdParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description()) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description()) } } #[cfg(all(feature = "cache", feature = "utils"))] impl StdError for UserIdParseError { fn description(&self) -> &str { use self::UserIdParseError::*; - + match *self { NotPresentInCache => "not present in cache", } @@ -129,7 +125,9 @@ impl FromStr for UserId { type Err = UserIdParseError; fn from_str(s: &str) -> StdResult<Self, Self::Err> { - utils::parse_username(s).ok_or_else(|| UserIdParseError::NotPresentInCache).map(UserId) + utils::parse_username(s) + .ok_or_else(|| UserIdParseError::NotPresentInCache) + .map(UserId) } } @@ -142,19 +140,17 @@ pub enum RoleParseError { #[cfg(all(feature = "model", feature = "utils"))] impl fmt::Display for RoleParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description()) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description()) } } #[cfg(all(feature = "cache", feature = "utils"))] impl StdError for RoleParseError { fn description(&self) -> &str { use self::RoleParseError::*; - + match *self { NotPresentInCache => "not present in cache", - InvalidRole => "invalid role" + InvalidRole => "invalid role", } } } @@ -184,16 +180,14 @@ pub enum RoleIdParseError { #[cfg(all(feature = "model", feature = "utils"))] impl fmt::Display for RoleIdParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description()) - } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.description()) } } #[cfg(all(feature = "cache", feature = "utils"))] impl StdError for RoleIdParseError { fn description(&self) -> &str { use self::RoleIdParseError::*; - + match *self { NotPresentInCache => "not present in cache", } @@ -205,7 +199,9 @@ impl FromStr for RoleId { type Err = RoleIdParseError; fn from_str(s: &str) -> StdResult<Self, Self::Err> { - utils::parse_role(s).ok_or_else(|| RoleIdParseError::NotPresentInCache).map(RoleId) + utils::parse_role(s) + .ok_or_else(|| RoleIdParseError::NotPresentInCache) + .map(RoleId) } } |