mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 19:00:46 +00:00
Use With trait for chainable variant
This commit is contained in:
parent
528e986fc3
commit
5a6c84a55e
@ -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.
|
||||
|
@ -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<Box<Fn(&mut Cursive) + Send>>;
|
||||
|
||||
@ -190,6 +190,8 @@ impl ProgressBar {
|
||||
}
|
||||
|
||||
/// Sets the color style.
|
||||
///
|
||||
/// The default color is `PaletteColor::Highlight`.
|
||||
pub fn set_color<C>(&mut self, color: C)
|
||||
where
|
||||
C: Into<ColorType>,
|
||||
@ -200,13 +202,11 @@ impl ProgressBar {
|
||||
/// Sets the color style.
|
||||
///
|
||||
/// 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
|
||||
C: Into<ColorType>,
|
||||
{
|
||||
self.color = color.into();
|
||||
|
||||
self
|
||||
self.with(|s| s.set_color(color))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user