0

Is there a way to use String::from with variables? I tried using it similarly to println!(), but doesn't seem to work.

String::from("[INFO]: {}", message)

Expected:
// Returns: "[INFO]: My info message here"

Got:
// Error: argument unexpected
paspielka
  • 15
  • 3

1 Answers1

0

Rust doesn’t really practice variadic functions because we have big metaprogramming potential: modern generic system and about 6 types of macros.

In this case you need the format macro:

format!("[INFO]: {}", message)
Miiao
  • 751
  • 1
  • 8