Make sure the visit_{enum,struct,tuple_struct} name is a &'static str

This commit is contained in:
Erick Tryzelaar
2015-07-29 12:07:29 -07:00
parent 6c9cebdcc3
commit 578a0178b5
2 changed files with 10 additions and 8 deletions
+7 -5
View File
@@ -211,7 +211,9 @@ pub trait Deserializer {
/// This method hints that the `Deserialize` type is expecting a named unit. This allows /// This method hints that the `Deserialize` type is expecting a named unit. This allows
/// deserializers to a named unit that aren't tagged as a named unit. /// deserializers to a named unit that aren't tagged as a named unit.
#[inline] #[inline]
fn visit_unit_struct<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error> fn visit_unit_struct<V>(&mut self,
_name: &'static str,
visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.visit_unit(visitor) self.visit_unit(visitor)
@@ -221,7 +223,7 @@ pub trait Deserializer {
/// deserializers to parse sequences that aren't tagged as sequences. /// deserializers to parse sequences that aren't tagged as sequences.
#[inline] #[inline]
fn visit_tuple_struct<V>(&mut self, fn visit_tuple_struct<V>(&mut self,
_name: &str, _name: &'static str,
len: usize, len: usize,
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
@@ -233,7 +235,7 @@ pub trait Deserializer {
/// deserializers to parse sequences that aren't tagged as maps. /// deserializers to parse sequences that aren't tagged as maps.
#[inline] #[inline]
fn visit_struct<V>(&mut self, fn visit_struct<V>(&mut self,
_name: &str, _name: &'static str,
_fields: &'static [&'static str], _fields: &'static [&'static str],
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
@@ -255,7 +257,7 @@ pub trait Deserializer {
/// type. /// type.
#[inline] #[inline]
fn visit_enum<V>(&mut self, fn visit_enum<V>(&mut self,
_enum: &str, _enum: &'static str,
_variants: &'static [&'static str], _variants: &'static [&'static str],
_visitor: V) -> Result<V::Value, Self::Error> _visitor: V) -> Result<V::Value, Self::Error>
where V: EnumVisitor, where V: EnumVisitor,
@@ -395,7 +397,7 @@ pub trait Visitor {
} }
#[inline] #[inline]
fn visit_unit_struct<E>(&mut self, _name: &str) -> Result<Self::Value, E> fn visit_unit_struct<E>(&mut self, _name: &'static str) -> Result<Self::Value, E>
where E: Error, where E: Error,
{ {
self.visit_unit() self.visit_unit()
+3 -3
View File
@@ -113,15 +113,15 @@ pub trait Serializer {
fn visit_unit(&mut self) -> Result<(), Self::Error>; fn visit_unit(&mut self) -> Result<(), Self::Error>;
#[inline] #[inline]
fn visit_unit_struct(&mut self, _name: &str) -> Result<(), Self::Error> { fn visit_unit_struct(&mut self, _name: &'static str) -> Result<(), Self::Error> {
self.visit_unit() self.visit_unit()
} }
#[inline] #[inline]
fn visit_enum_unit(&mut self, fn visit_enum_unit(&mut self,
_name: &str, _name: &'static str,
_variant_index: usize, _variant_index: usize,
_variant: &str) -> Result<(), Self::Error> { _variant: &'static str) -> Result<(), Self::Error> {
self.visit_unit() self.visit_unit()
} }