Revert serialization of features to string type
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 4 Apr 2018 18:07:57 +0000 (20:07 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 4 Apr 2018 18:07:57 +0000 (20:07 +0200)
src/cargo/core/summary.rs
tests/testsuite/metadata.rs

index 1c8d95b36e4d1a8d4b11123bd5e028c68c522248..83846c8229e6bd68677898ace12114deffa145de 100644 (file)
@@ -3,6 +3,9 @@ use std::mem;
 use std::rc::Rc;
 
 use semver::Version;
+
+use serde::{Serialize, Serializer};
+
 use core::{Dependency, PackageId, SourceId};
 use core::interning::InternedString;
 
@@ -190,7 +193,7 @@ fn build_feature_map(
 /// * A feature in a depedency
 ///
 /// The selection between these 3 things happens as part of the construction of the FeatureValue.
-#[derive(Clone, Debug, Serialize)]
+#[derive(Clone, Debug)]
 pub enum FeatureValue {
     Feature(InternedString),
     Crate(InternedString),
@@ -227,4 +230,20 @@ impl FeatureValue {
     }
 }
 
+impl Serialize for FeatureValue {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+    where
+        S: Serializer,
+    {
+        use self::FeatureValue::*;
+        match *self {
+            Feature(ref f) => serializer.serialize_str(f),
+            Crate(ref c) => serializer.serialize_str(c),
+            CrateFeature(ref c, ref f) => {
+                serializer.serialize_str(&[c.as_ref(), f.as_ref()].join("/"))
+            }
+        }
+    }
+}
+
 pub type FeatureMap = BTreeMap<String, Vec<FeatureValue>>;
index 34720c4b222d55bcd7123c388a23bfd81c5d11cb..074d5499d4ac640918579d4db8cc91969a80e83a 100644 (file)
@@ -192,9 +192,7 @@ optional_feat = []
                 ],
                 "features": {
                   "default": [
-                    {
-                       "Feature": "default_feat"
-                    }
+                      "default_feat"
                   ],
                   "default_feat": [],
                   "optional_feat": []