diff options
| author | Leah <[email protected]> | 2018-03-23 13:54:12 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2018-03-23 13:54:12 +0100 |
| commit | fdcf44e1463e708cd8b612c183e302db9af0febd (patch) | |
| tree | 1a311f26fb38522ba380881fa6e72c0c2e5c54bc /src/internal | |
| parent | Fix Create(Embed/Message) to be consistent (diff) | |
| download | serenity-fdcf44e1463e708cd8b612c183e302db9af0febd.tar.xz serenity-fdcf44e1463e708cd8b612c183e302db9af0febd.zip | |
Change the way ids and some enums are made (#295)
This makes them easier to be found by tools like rls.
Also update struct inits to use the shorthand version for `x: x`.
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/macros.rs | 13 | ||||
| -rw-r--r-- | src/internal/timer.rs | 2 |
2 files changed, 3 insertions, 12 deletions
diff --git a/src/internal/macros.rs b/src/internal/macros.rs index 875326a..c4d2b6f 100644 --- a/src/internal/macros.rs +++ b/src/internal/macros.rs @@ -99,16 +99,7 @@ macro_rules! feature_framework { } macro_rules! enum_number { - (#[$attr_:meta] $name:ident { $(#[$attr:meta] $variant:ident = $value:expr, )* }) => { - #[$attr_] - #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] - pub enum $name { - $( - #[$attr] - $variant = $value, - )* - } - + ($name:ident { $($variant:ident, )* }) => { impl ::serde::Serialize for $name { fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error> where S: ::serde::Serializer @@ -138,7 +129,7 @@ macro_rules! enum_number { // Rust does not come with a simple way of converting a // number to an enum, so use a big `match`. match value { - $( $value => Ok($name::$variant), )* + $( v if v == $name::$variant as u64 => Ok($name::$variant), )* _ => Err(E::custom( format!("unknown {} value: {}", stringify!($name), value))), diff --git a/src/internal/timer.rs b/src/internal/timer.rs index fa2fcc2..18ca672 100644 --- a/src/internal/timer.rs +++ b/src/internal/timer.rs @@ -14,7 +14,7 @@ impl Timer { Timer { due: Utc::now() + duration, - duration: duration, + duration, } } |