From fc5060a8e0c2b0f9f9c52aeb02f7b484fe99ecd0 Mon Sep 17 00:00:00 2001 From: mara <43048142+vmedea@users.noreply.github.com> Date: Fri, 8 May 2020 20:44:18 +0200 Subject: [PATCH] Fix the theme example (#452) - Remove the inline feature detection, it doesn't work for features of dependencies. Instead use `required-features` in `Cargo.toml` for the specific binary. - The asset moved one level up relatively to `../../assets/style.toml` --- examples/Cargo.toml | 3 +++ examples/src/bin/theme.rs | 39 ++++++++++++--------------------------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 5707c76..7a4dd03 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -20,3 +20,6 @@ cursive = { path = "../cursive", default-features=false } [features] default = ["cursive/default"] +[[bin]] +name = "theme" +required-features = ["cursive/toml"] diff --git a/examples/src/bin/theme.rs b/examples/src/bin/theme.rs index 50f5cf6..6bc58a9 100644 --- a/examples/src/bin/theme.rs +++ b/examples/src/bin/theme.rs @@ -3,35 +3,20 @@ use cursive::views::{Dialog, TextView}; fn main() { let mut siv = cursive::default(); - #[cfg(feature = "toml")] - { - // You can load a theme from a file at runtime for fast development. - siv.load_theme_file("assets/style.toml").unwrap(); + // You can load a theme from a file at runtime for fast development. + siv.load_theme_file("assets/style.toml").unwrap(); - // Or you can directly load it from a string for easy deployment. - siv.load_toml(include_str!("../assets/style.toml")).unwrap(); + // Or you can directly load it from a string for easy deployment. + siv.load_toml(include_str!("../../assets/style.toml")).unwrap(); - siv.add_layer( - Dialog::around(TextView::new( - "This application uses a \ - custom theme!", - )) - .title("Themed dialog") - .button("Quit", |s| s.quit()), - ); - } - - #[cfg(not(feature = "toml"))] - { - siv.add_layer( - Dialog::around(TextView::new( - "Run this example again with the `toml` feature!\n\n\ - cargo run --example theme --features toml", - )) - .title("Themed dialog - missing `toml` feature") - .button("Quit", |s| s.quit()), - ); - } + siv.add_layer( + Dialog::around(TextView::new( + "This application uses a \ + custom theme!", + )) + .title("Themed dialog") + .button("Quit", |s| s.quit()), + ); siv.run(); }