Skip to content

Commit

Permalink
Clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
itome committed Apr 24, 2024
1 parent 7da5ae4 commit 1dd9039
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/components/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ pub struct InspectorComponent {
action_tx: Option<UnboundedSender<ActionOrThunk>>,
}

impl<'a> InspectorComponent {
impl Default for InspectorComponent {
fn default() -> Self {
Self::new()
}
}

impl InspectorComponent {
pub fn new() -> Self {
Self { action_tx: None }
}

fn item_builder(item: &DiagnosticNode) -> Node<'a> {
fn item_builder(item: &DiagnosticNode) -> Node {
if let Some(children) = item.children.as_ref() {
let children = children.iter().map(Self::item_builder).collect();
Node::new(
Expand Down
16 changes: 11 additions & 5 deletions src/widgets/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ pub struct TreeState {
pub opened: HashSet<String>,
}

impl Default for TreeState {
fn default() -> Self {
Self::new()
}
}

impl TreeState {
pub fn new() -> Self {
TreeState {
Expand Down Expand Up @@ -111,10 +117,10 @@ impl<'a> Tree<'a> {
pub fn make_lines(
node: &Node<'a>,
state: &TreeState,
prefix_for_root: &Vec<Span<'a>>,
prefix_for_children: &Vec<Span<'a>>,
prefix_for_root: &[Span<'a>],
prefix_for_children: &[Span<'a>],
) -> Vec<(String, Line<'a>)> {
let mut root_item: Vec<Span> = prefix_for_root.clone();
let mut root_item: Vec<Span> = prefix_for_root.to_vec();

if node.children.is_empty() {
root_item.push(Span::raw("─"));
Expand All @@ -133,13 +139,13 @@ impl<'a> Tree<'a> {

if state.opened.contains(&node.id) {
for (i, child) in node.children.iter().enumerate() {
let mut child_prefix_for_root = prefix_for_children.clone();
let mut child_prefix_for_root = prefix_for_children.to_vec();
if i == node.children.len().wrapping_sub(1) {
child_prefix_for_root.push(Span::raw("╰"));
} else {
child_prefix_for_root.push(Span::raw("├"));
}
let mut child_prefix_for_children = prefix_for_children.clone();
let mut child_prefix_for_children = prefix_for_children.to_vec();
if i != node.children.len().wrapping_sub(1) {
child_prefix_for_children.push(Span::raw("│"));
} else {
Expand Down

0 comments on commit 1dd9039

Please sign in to comment.