Impl RefFlags::into_toml() as Into<Value> for RefFlags

This commit is contained in:
Matthias Beyer 2016-06-09 19:39:17 +02:00
parent 14cd99f5f2
commit 57e653e384

View file

@ -32,13 +32,6 @@ impl RefFlags {
})
}
/// Build a TOML::Value from this RefFlags object.
///
/// Returns a Map which should be set in `ref.flags` in the header.
pub fn into_toml(self) -> Result<Value> {
unimplemented!()
}
/// Alias for `RefFlags::content_hashing()`
pub fn is_often_moving(mut self, b: bool) -> RefFlags {
self.with_content_hashing(b)
@ -64,3 +57,17 @@ impl RefFlags {
}
impl Into<Value> for RefFlags {
/// Build a TOML::Value from this RefFlags object.
///
/// Returns a Map which should be set in `ref.flags` in the header.
fn into(self) -> Value {
let mut btm = BTreeMap::new();
btm.insert(String::from("content_hashing"), Value::Boolean(self.content_hashing));
btm.insert(String::from("permission_tracking"), Value::Boolean(self.permission_tracking));
return Value::Table(btm)
}
}