Skip to content

Commit

Permalink
tree-wide: replace impl Default with better_default attribute macros
Browse files Browse the repository at this point in the history
  • Loading branch information
davvid committed Nov 12, 2024
1 parent d66ca84 commit f22f6d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/cmds/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::atomic;

use anyhow::Result;
use better_default::Default;
use clap::{CommandFactory, FromArgMatches, Parser};
use rayon::prelude::*;
use yansi::Paint;
Expand Down Expand Up @@ -181,9 +182,11 @@ pub struct CmdParams {
force: bool,
keep_going: bool,
num_jobs: Option<usize>,
#[default(true)]
exit_on_error: bool,
quiet: bool,
verbose: u8,
#[default(true)]
word_split: bool,
}

Expand Down
31 changes: 3 additions & 28 deletions src/model.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::cell::{Cell, UnsafeCell};
use std::str::FromStr;

use better_default::Default;
use indextree::{Arena, NodeId};
use is_terminal::IsTerminal;
use strum::VariantNames;
Expand Down Expand Up @@ -183,7 +184,7 @@ impl MultiVariable {
}

/// Trees represent a single worktree
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct Tree {
pub commands: MultiVariableMap,
pub environment: Vec<MultiVariable>,
Expand All @@ -195,6 +196,7 @@ pub struct Tree {
pub branch: Variable,
pub(crate) branches: VariableMap,
pub worktree: Variable,
#[default(string!("origin"))]
pub(crate) default_remote: String,
pub(crate) clone_depth: i64,
pub(crate) is_single_branch: bool,
Expand All @@ -210,33 +212,6 @@ pub struct Tree {

impl_display!(Tree);

impl Default for Tree {
fn default() -> Self {
Self {
commands: MultiVariableMap::new(),
environment: Vec::new(),
gitconfig: MultiVariableMap::new(),
remotes: VariableMap::new(),
symlink: Variable::new(string!(""), None),
templates: StringSet::new(),
variables: VariableMap::new(),
branch: Variable::new(string!(""), None),
branches: VariableMap::new(),
worktree: Variable::new(string!(""), None),
default_remote: string!("origin"),
clone_depth: 0,
is_single_branch: false,
is_symlink: false,
is_bare_repository: false,
is_worktree: false,
description: string!(""),
links: Vec::new(),
name: string!(""),
path: Variable::new(string!(""), None),
}
}
}

impl Tree {
pub fn get_name(&self) -> &String {
&self.name
Expand Down

0 comments on commit f22f6d9

Please sign in to comment.