Change document_shape to work on reference

We don't need to clone those for the following display.
This commit is contained in:
sholderbach 2024-08-05 11:52:11 +02:00
parent 4ffdbf4d93
commit c88fb790f8

View File

@ -148,7 +148,7 @@ fn get_documentation(
format!( format!(
" {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {}", " {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {}",
String::from_utf8_lossy(kw), String::from_utf8_lossy(kw),
document_shape(*shape.clone()), document_shape(&shape),
positional.desc positional.desc
) )
} }
@ -156,7 +156,7 @@ fn get_documentation(
format!( format!(
" {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}", " {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}",
positional.name, positional.name,
document_shape(positional.shape.clone()), document_shape(&positional.shape),
positional.desc positional.desc
) )
} }
@ -169,7 +169,7 @@ fn get_documentation(
format!( format!(
" {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {} (optional)", " {help_subcolor_one}\"{}\" + {RESET}<{help_subcolor_two}{}{RESET}>: {} (optional)",
String::from_utf8_lossy(kw), String::from_utf8_lossy(kw),
document_shape(*shape.clone()), document_shape(&shape),
positional.desc positional.desc
) )
} }
@ -190,7 +190,7 @@ fn get_documentation(
format!( format!(
" {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}{}", " {help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}{}",
positional.name, positional.name,
document_shape(positional.shape.clone()), document_shape(&positional.shape),
positional.desc, positional.desc,
opt_suffix, opt_suffix,
) )
@ -204,7 +204,7 @@ fn get_documentation(
long_desc, long_desc,
" ...{help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}", " ...{help_subcolor_one}{}{RESET} <{help_subcolor_two}{}{RESET}>: {}",
rest_positional.name, rest_positional.name,
document_shape(rest_positional.shape.clone()), document_shape(&rest_positional.shape),
rest_positional.desc rest_positional.desc
); );
} }
@ -495,9 +495,9 @@ impl HelpStyle {
} }
/// Make syntax shape presentable by stripping custom completer info /// Make syntax shape presentable by stripping custom completer info
pub fn document_shape(shape: SyntaxShape) -> SyntaxShape { fn document_shape(shape: &SyntaxShape) -> &SyntaxShape {
match shape { match shape {
SyntaxShape::CompleterWrapper(inner_shape, _) => *inner_shape, SyntaxShape::CompleterWrapper(inner_shape, _) => inner_shape,
_ => shape, _ => shape,
} }
} }