From 5a6c84a55e0813bcbee69e8c911c896d636e79ed Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 8 Aug 2018 10:24:40 -0700 Subject: [PATCH] Use With trait for chainable variant --- src/theme/palette.rs | 2 +- src/views/progress_bar.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/theme/palette.rs b/src/theme/palette.rs index 2192552..469b2e5 100644 --- a/src/theme/palette.rs +++ b/src/theme/palette.rs @@ -225,7 +225,7 @@ pub(crate) fn load_toml(palette: &mut Palette, table: &toml::value::Table) { /// Color entry in a palette. /// -/// Each `ColorRole` is used for a specific role in a default application. +/// Each `PaletteColor` is used for a specific role in a default application. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Enum)] pub enum PaletteColor { /// Color used for the application background. diff --git a/src/views/progress_bar.rs b/src/views/progress_bar.rs index 1c05564..176b020 100644 --- a/src/views/progress_bar.rs +++ b/src/views/progress_bar.rs @@ -4,7 +4,7 @@ use std::thread; use theme::{ColorStyle, ColorType, Effect}; use utils::Counter; use view::View; -use Printer; +use {Printer, With}; // pub type CbPromise = Option>; @@ -190,6 +190,8 @@ impl ProgressBar { } /// Sets the color style. + /// + /// The default color is `PaletteColor::Highlight`. pub fn set_color(&mut self, color: C) where C: Into, @@ -200,13 +202,11 @@ impl ProgressBar { /// Sets the color style. /// /// Chainable variant of `set_color`. - pub fn with_color(mut self, color: C) -> Self + pub fn with_color(self, color: C) -> Self where C: Into, { - self.color = color.into(); - - self + self.with(|s| s.set_color(color)) } }