diff --git a/examples/theme.rs b/examples/theme.rs index 4798e54..c9cde61 100644 --- a/examples/theme.rs +++ b/examples/theme.rs @@ -1,7 +1,7 @@ extern crate cursive; use cursive::views::{Dialog, TextView}; -use cursive::Cursive; +use cursive::{thene, Cursive}; fn main() { let mut siv = Cursive::default(); @@ -9,7 +9,7 @@ fn main() { siv.load_theme_file("assets/style.toml").unwrap(); // Or you can directly load it from a string for easy deployment. - // siv.load_theme(include_str!("../assets/style.toml")).unwrap(); + siv.load_toml(include_str!("../assets/style.toml").unwrap()); siv.add_layer( Dialog::around(TextView::new( diff --git a/src/cursive.rs b/src/cursive.rs index 73f3c57..69310ea 100644 --- a/src/cursive.rs +++ b/src/cursive.rs @@ -313,16 +313,14 @@ impl Cursive { pub fn load_theme_file>( &mut self, filename: P, ) -> Result<(), theme::Error> { - self.set_theme(try!(theme::load_theme_file(filename))); - Ok(()) + theme::load_theme_file(filename).map(|theme| self.set_theme(theme)) } /// Loads a theme from the given string content. /// /// Content must be valid toml. pub fn load_toml(&mut self, content: &str) -> Result<(), theme::Error> { - self.set_theme(try!(theme::load_toml(content))); - Ok(()) + theme::load_toml(content).map(|theme| self.set_theme(theme)) } /// Sets the refresh rate, in frames per second.