From c88fb790f8dfb87b798cbdfda0fcaa35a8985342 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Mon, 5 Aug 2024 11:52:11 +0200 Subject: [PATCH] Change `document_shape` to work on reference We don't need to clone those for the following display. --- crates/nu-engine/src/documentation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index b55dc3c545..fb178ddd32 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -148,7 +148,7 @@ fn get_documentation( format!( " {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {}", String::from_utf8_lossy(kw), - document_shape(*shape.clone()), + document_shape(&shape), positional.desc ) } @@ -156,7 +156,7 @@ fn get_documentation( format!( " {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}", positional.name, - document_shape(positional.shape.clone()), + document_shape(&positional.shape), positional.desc ) } @@ -169,7 +169,7 @@ fn get_documentation( format!( " {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {} (optional)", String::from_utf8_lossy(kw), - document_shape(*shape.clone()), + document_shape(&shape), positional.desc ) } @@ -190,7 +190,7 @@ fn get_documentation( format!( " {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}{}", positional.name, - document_shape(positional.shape.clone()), + document_shape(&positional.shape), positional.desc, opt_suffix, ) @@ -204,7 +204,7 @@ fn get_documentation( long_desc, " ...{help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}", rest_positional.name, - document_shape(rest_positional.shape.clone()), + document_shape(&rest_positional.shape), rest_positional.desc ); } @@ -495,9 +495,9 @@ impl HelpStyle { } /// Make syntax shape presentable by stripping custom completer info -pub fn document_shape(shape: SyntaxShape) -> SyntaxShape { +fn document_shape(shape: &SyntaxShape) -> &SyntaxShape { match shape { - SyntaxShape::CompleterWrapper(inner_shape, _) => *inner_shape, + SyntaxShape::CompleterWrapper(inner_shape, _) => inner_shape, _ => shape, } }