diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/src/config.rs b/src/config.rs index 2bc4322e..6a656a36 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,7 +18,7 @@ use font::Size; use serde_yaml; use serde::{self, de, Deserialize}; use serde::de::Error as SerdeError; -use serde::de::{Visitor, MapVisitor, Unexpected}; +use serde::de::{Visitor, MapAccess, Unexpected}; use notify::{Watcher as WatcherApi, RecommendedWatcher as FileWatcher, op}; use glutin::ModifiersState; @@ -52,8 +52,8 @@ pub struct ClickHandler { pub threshold: Duration, } -fn deserialize_duration_ms<D>(deserializer: D) -> ::std::result::Result<Duration, D::Error> - where D: de::Deserializer +fn deserialize_duration_ms<'a, D>(deserializer: D) -> ::std::result::Result<Duration, D::Error> + where D: de::Deserializer<'a> { let threshold_ms = u64::deserialize(deserializer)?; Ok(Duration::from_millis(threshold_ms)) @@ -351,13 +351,13 @@ impl ModsWrapper { } } -impl de::Deserialize for ModsWrapper { +impl<'a> de::Deserialize<'a> for ModsWrapper { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { struct ModsVisitor; - impl Visitor for ModsVisitor { + impl<'a> Visitor<'a> for ModsVisitor { type Value = ModsWrapper; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -394,13 +394,13 @@ impl ActionWrapper { } } -impl de::Deserialize for ActionWrapper { +impl<'a> de::Deserialize<'a> for ActionWrapper { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { struct ActionVisitor; - impl Visitor for ActionVisitor { + impl<'a> Visitor<'a> for ActionVisitor { type Value = ActionWrapper; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -441,13 +441,13 @@ struct ModeWrapper { pub not_mode: TermMode, } -impl de::Deserialize for ModeWrapper { +impl<'a> de::Deserialize<'a> for ModeWrapper { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { struct ModeVisitor; - impl Visitor for ModeVisitor { + impl<'a> Visitor<'a> for ModeVisitor { type Value = ModeWrapper; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -487,13 +487,13 @@ impl MouseButton { } } -impl de::Deserialize for MouseButton { +impl<'a> de::Deserialize<'a> for MouseButton { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { struct MouseButtonVisitor; - impl Visitor for MouseButtonVisitor { + impl<'a> Visitor<'a> for MouseButtonVisitor { type Value = MouseButton; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -563,9 +563,9 @@ impl RawBinding { } } -impl de::Deserialize for RawBinding { +impl<'a> de::Deserialize<'a> for RawBinding { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { enum Field { Key, @@ -577,9 +577,9 @@ impl de::Deserialize for RawBinding { Command, } - impl de::Deserialize for Field { + impl<'a> de::Deserialize<'a> for Field { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Field, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { struct FieldVisitor; @@ -587,7 +587,7 @@ impl de::Deserialize for RawBinding { "key", "mods", "mode", "action", "chars", "mouse", "command", ]; - impl Visitor for FieldVisitor { + impl<'a> Visitor<'a> for FieldVisitor { type Value = Field; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -610,12 +610,12 @@ impl de::Deserialize for RawBinding { } } - deserializer.deserialize_struct_field(FieldVisitor) + deserializer.deserialize_struct("Field", FIELDS, FieldVisitor) } } struct RawBindingVisitor; - impl Visitor for RawBindingVisitor { + impl<'a> Visitor<'a> for RawBindingVisitor { type Value = RawBinding; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -624,9 +624,9 @@ impl de::Deserialize for RawBinding { fn visit_map<V>( self, - mut visitor: V + mut map: V ) -> ::std::result::Result<RawBinding, V::Error> - where V: MapVisitor, + where V: MapAccess<'a>, { let mut mods: Option<ModifiersState> = None; let mut key: Option<::glutin::VirtualKeyCode> = None; @@ -639,14 +639,14 @@ impl de::Deserialize for RawBinding { use ::serde::de::Error; - while let Some(struct_key) = visitor.visit_key::<Field>()? { + while let Some(struct_key) = map.next_key::<Field>()? { match struct_key { Field::Key => { if key.is_some() { return Err(<V::Error as Error>::duplicate_field("key")); } - let coherent_key = visitor.visit_value::<Key>()?; + let coherent_key = map.next_value::<Key>()?; key = Some(coherent_key.to_glutin_key()); }, Field::Mods => { @@ -654,14 +654,14 @@ impl de::Deserialize for RawBinding { return Err(<V::Error as Error>::duplicate_field("mods")); } - mods = Some(visitor.visit_value::<ModsWrapper>()?.into_inner()); + mods = Some(map.next_value::<ModsWrapper>()?.into_inner()); }, Field::Mode => { if mode.is_some() { return Err(<V::Error as Error>::duplicate_field("mode")); } - let mode_deserializer = visitor.visit_value::<ModeWrapper>()?; + let mode_deserializer = map.next_value::<ModeWrapper>()?; mode = Some(mode_deserializer.mode); not_mode = Some(mode_deserializer.not_mode); }, @@ -670,28 +670,28 @@ impl de::Deserialize for RawBinding { return Err(<V::Error as Error>::duplicate_field("action")); } - action = Some(visitor.visit_value::<ActionWrapper>()?.into_inner()); + action = Some(map.next_value::<ActionWrapper>()?.into_inner()); }, Field::Chars => { if chars.is_some() { return Err(<V::Error as Error>::duplicate_field("chars")); } - chars = Some(visitor.visit_value()?); + chars = Some(map.next_value()?); }, Field::Mouse => { if chars.is_some() { return Err(<V::Error as Error>::duplicate_field("mouse")); } - mouse = Some(visitor.visit_value::<MouseButton>()?.into_inner()); + mouse = Some(map.next_value::<MouseButton>()?.into_inner()); }, Field::Command => { if command.is_some() { return Err(<V::Error as Error>::duplicate_field("command")); } - command = Some(visitor.visit_value::<CommandWrapper>()?); + command = Some(map.next_value::<CommandWrapper>()?); }, } } @@ -741,18 +741,18 @@ impl de::Deserialize for RawBinding { } -impl de::Deserialize for Alpha { +impl<'a> de::Deserialize<'a> for Alpha { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { let value = f32::deserialize(deserializer)?; Ok(Alpha::new(value)) } } -impl de::Deserialize for MouseBinding { +impl<'a> de::Deserialize<'a> for MouseBinding { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { let raw = RawBinding::deserialize(deserializer)?; raw.into_mouse_binding() @@ -760,9 +760,9 @@ impl de::Deserialize for MouseBinding { } } -impl de::Deserialize for KeyBinding { +impl<'a> de::Deserialize<'a> for KeyBinding { fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: de::Deserializer + where D: de::Deserializer<'a> { let raw = RawBinding::deserialize(deserializer)?; raw.into_key_binding() @@ -799,8 +799,8 @@ pub struct Colors { pub dim: Option<AnsiColors>, } -fn deserialize_cursor_colors<D>(deserializer: D) -> ::std::result::Result<CursorColors, D::Error> - where D: de::Deserializer +fn deserialize_cursor_colors<'a, D>(deserializer: D) -> ::std::result::Result<CursorColors, D::Error> + where D: de::Deserializer<'a> { let either = CursorOrPrimaryColors::deserialize(deserializer)?; Ok(either.into_cursor_colors()) @@ -925,12 +925,12 @@ pub struct AnsiColors { /// /// This is *not* the deserialize impl for Rgb since we want a symmetric /// serialize/deserialize impl for ref tests. -fn rgb_from_hex<D>(deserializer: D) -> ::std::result::Result<Rgb, D::Error> - where D: de::Deserializer +fn rgb_from_hex<'a, D>(deserializer: D) -> ::std::result::Result<Rgb, D::Error> + where D: de::Deserializer<'a> { struct RgbVisitor; - impl ::serde::de::Visitor for RgbVisitor { + impl<'a> Visitor<'a> for RgbVisitor { type Value = Rgb; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -1296,13 +1296,13 @@ impl Default for Delta { } trait DeserializeFromF32 : Sized { - fn deserialize_from_f32<D>(D) -> ::std::result::Result<Self, D::Error> - where D: serde::de::Deserializer; + fn deserialize_from_f32<'a, D>(D) -> ::std::result::Result<Self, D::Error> + where D: serde::de::Deserializer<'a>; } impl DeserializeFromF32 for Size { - fn deserialize_from_f32<D>(deserializer: D) -> ::std::result::Result<Self, D::Error> - where D: serde::de::Deserializer + fn deserialize_from_f32<'a, D>(deserializer: D) -> ::std::result::Result<Self, D::Error> + where D: serde::de::Deserializer<'a> { use std::marker::PhantomData; @@ -1310,8 +1310,8 @@ impl DeserializeFromF32 for Size { _marker: PhantomData<__D>, } - impl<__D> ::serde::de::Visitor for FloatVisitor<__D> - where __D: ::serde::de::Deserializer + impl<'a, __D> Visitor<'a> for FloatVisitor<__D> + where __D: serde::de::Deserializer<'a> { type Value = f64; |