Use With trait for chainable variant

This commit is contained in:
Alexandre Bury 2018-08-08 10:24:40 -07:00
parent 528e986fc3
commit 5a6c84a55e
2 changed files with 6 additions and 6 deletions

View File

@ -225,7 +225,7 @@ pub(crate) fn load_toml(palette: &mut Palette, table: &toml::value::Table) {
/// Color entry in a palette. /// 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)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Enum)]
pub enum PaletteColor { pub enum PaletteColor {
/// Color used for the application background. /// Color used for the application background.

View File

@ -4,7 +4,7 @@ use std::thread;
use theme::{ColorStyle, ColorType, Effect}; use theme::{ColorStyle, ColorType, Effect};
use utils::Counter; use utils::Counter;
use view::View; use view::View;
use Printer; use {Printer, With};
// pub type CbPromise = Option<Box<Fn(&mut Cursive) + Send>>; // pub type CbPromise = Option<Box<Fn(&mut Cursive) + Send>>;
@ -190,6 +190,8 @@ impl ProgressBar {
} }
/// Sets the color style. /// Sets the color style.
///
/// The default color is `PaletteColor::Highlight`.
pub fn set_color<C>(&mut self, color: C) pub fn set_color<C>(&mut self, color: C)
where where
C: Into<ColorType>, C: Into<ColorType>,
@ -200,13 +202,11 @@ impl ProgressBar {
/// Sets the color style. /// Sets the color style.
/// ///
/// Chainable variant of `set_color`. /// Chainable variant of `set_color`.
pub fn with_color<C>(mut self, color: C) -> Self pub fn with_color<C>(self, color: C) -> Self
where where
C: Into<ColorType>, C: Into<ColorType>,
{ {
self.color = color.into(); self.with(|s| s.set_color(color))
self
} }
} }