refactor: impl method returns Self

This commit is contained in:
EdJoPaTo
2021-04-01 09:05:05 +02:00
parent d5798982d1
commit cf31797e86
4 changed files with 26 additions and 26 deletions
+2 -2
View File
@@ -20,8 +20,8 @@ struct App<'a> {
}
impl<'a> App<'a> {
fn new() -> App<'a> {
App {
fn new() -> Self {
Self {
tree: StatefulTree::with_items(vec![
TreeItem::new_leaf("a"),
TreeItem::new(
+6 -6
View File
@@ -25,8 +25,8 @@ pub struct Config {
}
impl Default for Config {
fn default() -> Config {
Config {
fn default() -> Self {
Self {
exit_key: Key::Char('q'),
tick_rate: Duration::from_millis(250),
}
@@ -34,11 +34,11 @@ impl Default for Config {
}
impl Events {
pub fn new() -> Events {
Events::with_config(Config::default())
pub fn new() -> Self {
Self::with_config(Config::default())
}
pub fn with_config(config: Config) -> Events {
pub fn with_config(config: Config) -> Self {
let (tx, rx) = mpsc::channel();
{
let tx = tx.clone();
@@ -63,7 +63,7 @@ impl Events {
}
thread::sleep(config.tick_rate);
});
Events { rx }
Self { rx }
}
pub fn next(&self) -> Result<Event<Key>, mpsc::RecvError> {
+4 -4
View File
@@ -9,15 +9,15 @@ pub struct StatefulTree<'a> {
impl<'a> StatefulTree<'a> {
#[allow(dead_code)]
pub fn new() -> StatefulTree<'a> {
StatefulTree {
pub fn new() -> Self {
Self {
state: TreeState::default(),
items: Vec::new(),
}
}
pub fn with_items(items: Vec<TreeItem<'a>>) -> StatefulTree<'a> {
StatefulTree {
pub fn with_items(items: Vec<TreeItem<'a>>) -> Self {
Self {
state: TreeState::default(),
items,
}