Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created February 24, 2015 22:26
Show Gist options
  • Save adamhjk/48774993c1d2c4b3fd1b to your computer and use it in GitHub Desktop.
Save adamhjk/48774993c1d2c4b3fd1b to your computer and use it in GitHub Desktop.
This used to work..
use rustc_serialize::Encodable;
use toml;
#[derive(RustcEncodable, Clone)]
pub struct Config {
pub server: Option<String>,
pub user: Option<String>,
pub enterprise: Option<String>,
pub organization: Option<String>,
pub project: Option<String>,
pub git_port: Option<String>,
pub pipeline: Option<String>
}
impl Config {
pub fn write_file(&self, path: &Path) -> Result<(), DeliveryError> {
let write_dir = path.join_many(&[".delivery"]);
if !write_dir.is_dir() {
try!(mkdir_recursive(&write_dir, old_io::USER_RWX));
}
let write_path = path.join_many(&[".delivery", "cli.toml"]);
say("white", "Writing configuration to ");
sayln("yellow", &format!("{}", write_path.display()));
let mut f = try!(File::create(&write_path));
let toml_string = toml::encode_str(self);
sayln("magenta", "New configuration");
sayln("magenta", "-----------------");
say("white", &toml_string);
try!(f.write_all(toml_string.as_bytes()));
Ok(())
}
}
// It now fails with:
// src/delivery/config/mod.rs:88:27: 88:43 error: the trait `rustc-serialize::serialize::Encodable` is not implemented for the type `config::Config` [E0277]
// src/delivery/config/mod.rs:88 let toml_string = toml::encode_str(self);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment