Skip to main content

rustmotion_core/traits/
backgrounded.rs

1pub trait Backgrounded {
2    fn background(&self) -> Option<&str>;
3}
4
5pub trait BackgroundedMut: Backgrounded {
6    fn set_background(&mut self, bg: Option<String>);
7}
8
9pub trait BackgroundedExt: BackgroundedMut + Sized {
10    fn bg(mut self, color: impl Into<String>) -> Self {
11        self.set_background(Some(color.into()));
12        self
13    }
14
15    fn bg_none(mut self) -> Self {
16        self.set_background(None);
17        self
18    }
19}
20
21impl<T: BackgroundedMut + Sized> BackgroundedExt for T {}