How to concatenate a literal string with a const string?
<p>I am trying to instantiate an argument parser (clap).
There is code like:</p>

<pre><code>const DEFAULT_VALUE: &amp;'static str = "12312312";
// ...
.help("this parameter is for (default:" + DEFAULT_VALUE + ")")
// ...
</code></pre>

<p>I looked through similar existing questions and discovered concat! macro and lazy_static.</p>

<p>First option doesn't fit and there is no example for lazy_static.
If it's possible it's will be over complicated anyway because lazy_static requires to define a block in a separate place.</p>

<p>I am looking some concise syntax sugar with a macro in place, without a lot of type overhead.</p>

<p>If define a local variable it could get to high because DSL for clap could be very long. It's not convenient, because it rips the string from its logical place in code.</p>

<p>Another approach to define static variable for the whole help string but it posses the same drawback as the approach above plus namespace pollution.</p>

<hr>

<p>Suggested solution with format! doesn't fit too. It requires to define a local variable.</p>

<hr>

<p>Example </p>

<pre><code>extern crate clap;

use clap::{Arg, App};

const DEFAULT: &amp;'static str = "1";

fn main() {
    let params = App::new("app")
        .arg(Arg::with_name("p")
             // here 100 lines of the uninterruptable expression
             .help(&amp;format!("parameter p (DEFAULT: {})", DEFAULT)))
             // here also 100 lines of the uninterruptable expression
        .get_matches();
    println!("param p = {}", params.value_of("p").unwrap())
}
</code></pre>

<p>Cargo.toml</p>

<pre><code>[package]

name = "demo-clap"
version = "1.0.0"
[dependencies]

clap = "2.10.0"
</code></pre>

<p>Compilation error</p>

<pre><code>&lt;std macros&gt;:2:1: 2:61 error: borrowed value does not live long enough
&lt;std macros&gt;:2 $ crate :: fmt :: format ( format_args ! ( $ ( $ arg ) * ) ) )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:11:21: 11:66 note: in this expansion of format! (defined in &lt;std macros&gt;)
src/main.rs:13:24: 15:2 note: reference must be valid for the block suffix following statement 0 at 13:23...
src/main.rs:13         .get_matches();
                                      ^
src/main.rs:8:5: 13:24 note: ...but borrowed value is only valid for the statement at 8:4
src/main.rs:8     let params = App::new("app")
                  ^
src/main.rs:8:5: 13:24 help: consider using a `let` binding to increase its lifetime
src/main.rs:8     let params = App::new("app")
                  ^
error: aborting due to previous error
error: Could not compile `demo-clap`.
</code></pre>