macro

concat! — Join literals into a static string

Combine supported literals into a static string slice at compilation. Numeric and other supported literal values are represented as text. Use format! for values computed during execution. Expression result: &'static str. Expected result (not executed): stdout: '/api/v2/items\n'; no stderr. Common mistake: Passing an ordinary local variable to concat! instead of a supported literal.

Formal Syntax & Structure

rust syntaxrust
concat!(literal, literal, ...)

Working Example

Example Snippetrust
fn main() {    const ROUTE: &str = concat!("/api/", "v", 2, "/items");    println!("{ROUTE}");}
Rust Reference