0

In Rust, we are able to use str::repeat -> String to repeat a string slice n times and get a String.

let pound_symbols = "#".repeat(5); // "#####" as String

However, this is evaluated on runtime. Is there a way to repeat the same character n times (which is constant) on compile time? Maybe a macro?

Using Rust 1.68.0

Mike Szyndel
  • 10,461
  • 10
  • 47
  • 63
Eray Erdin
  • 2,633
  • 1
  • 32
  • 66

0 Answers0