Help with understanding print!() with string literal

⚓ Rust    📅 2025-12-20    👤 surdeus    👁️ 1      

surdeus

i am not able to understand why

    let s = "hello";
    print!("{}", s);

works but not this:

    let s = "hello";
    print!(s);

s is storing a string literal according to my understanding. the same thing works well in C's printf() but not working here.

can anyone help me in this regard?

thank you.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed