From 3736693836aa5a77cf5310492784e918b1164696 Mon Sep 17 00:00:00 2001 From: KAMADA Ken'ichi Date: Thu, 11 May 2017 23:18:33 +0900 Subject: [PATCH] Treat the built-in tag information as static data. --- src/tag.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tag.rs b/src/tag.rs index 7d3e408..3acdbf5 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -71,20 +71,20 @@ impl Tag { /// Returns the description of the tag. #[inline] pub fn description(&self) -> Option<&str> { - get_tag_info(self).map(|ti| ti.desc) + get_tag_info(*self).map(|ti| ti.desc) } /// Returns the default value of the tag. `None` is returned if /// it is not defined in the standard or it depends on the context. #[inline] pub fn default_value(&self) -> Option { - get_tag_info(self).and_then(|ti| (&ti.default).into()) + get_tag_info(*self).and_then(|ti| (&ti.default).into()) } } impl fmt::Display for Tag { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match get_tag_info(self) { + match get_tag_info(*self) { Some(ti) => f.pad(ti.name), None => f.pad(&format!("{:?}", self)), } @@ -153,8 +153,8 @@ macro_rules! generate_well_known_tag_constants { )+)+ } - fn get_tag_info(tag: &Tag) -> Option<&tag_info::TagInfo> { - match *tag { + fn get_tag_info(tag: Tag) -> Option<&'static tag_info::TagInfo> { + match tag { $($( constants::$name => Some(&tag_info::$name), )+)+