mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
uucore: remove string leak in format_usage
This commit is contained in:
parent
84b7ecd32d
commit
d6753d8914
1 changed files with 3 additions and 3 deletions
|
@ -98,10 +98,10 @@ macro_rules! bin {
|
||||||
/// Generate the usage string for clap.
|
/// Generate the usage string for clap.
|
||||||
///
|
///
|
||||||
/// This function replaces all occurrences of `{}` with the execution phrase
|
/// This function replaces all occurrences of `{}` with the execution phrase
|
||||||
/// and leaks the result to return a `&'static str`. It does **not** support
|
/// and returns the resulting `String`. It does **not** support
|
||||||
/// more advanced formatting features such as `{0}`.
|
/// more advanced formatting features such as `{0}`.
|
||||||
pub fn format_usage(s: &str) -> &'static str {
|
pub fn format_usage(s: &str) -> String {
|
||||||
&*Box::leak(s.replace("{}", crate::execution_phrase()).into_boxed_str())
|
s.replace("{}", crate::execution_phrase())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_utility_is_second_arg() -> bool {
|
pub fn get_utility_is_second_arg() -> bool {
|
||||||
|
|
Loading…
Reference in a new issue