How to concatenate a char onto a string in Rust?

后端 未结 1 491
故里飘歌
故里飘歌 2021-01-07 18:48

I have tried using the to_string method on the char but this returns a &str when I need a String.

相关标签:
1条回答
  • 2021-01-07 19:34

    Using String::push method is the easiest method:

    let mut str = String::from("Hello World");
    str.push('!');
    
    0 讨论(0)
提交回复
热议问题