diff --git a/Cargo.toml b/Cargo.toml index e0ad628..a6156a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ version = "0.6" [dependencies] num = "0.1" odds = "0.2" -toml = "0.2" +toml = "0.3" unicode-segmentation = "1.0" unicode-width = "0.1" diff --git a/src/theme.rs b/src/theme.rs index 36c41de..6e63f9e 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -210,7 +210,7 @@ impl Default for Theme { } impl Theme { - fn load(&mut self, table: &toml::Table) { + fn load(&mut self, table: &toml::value::Table) { if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") { self.shadow = shadow; } @@ -314,7 +314,7 @@ pub struct Palette { impl Palette { /// Fills `self` with the colors from the given `table`. - fn load(&mut self, table: &toml::Table) { + fn load(&mut self, table: &toml::value::Table) { load_color(&mut self.background, table.get("background")); load_color(&mut self.shadow, table.get("shadow")); load_color(&mut self.view, table.get("view")); @@ -413,7 +413,7 @@ pub enum Error { /// An error occured when reading the file. Io(io::Error), /// An error occured when parsing the toml content. - Parse, + Parse(toml::de::Error), } impl From for Error { @@ -422,6 +422,12 @@ impl From for Error { } } +impl From for Error { + fn from(err: toml::de::Error) -> Self { + Error::Parse(err) + } +} + impl Color { fn parse(value: &str) -> Option { Some(match value { @@ -490,8 +496,7 @@ pub fn load_theme_file>(filename: P) -> Result { /// Loads a theme string and sets it as active. pub fn load_theme(content: &str) -> Result { - let mut parser = toml::Parser::new(content); - let table = try!(parser.parse().ok_or(Error::Parse)); + let table = toml::de::from_str(content)?; let mut theme = Theme::default(); theme.load(&table);