How to concatenate a string in Rust?

Hi Guys,

I am trying to do a very simple string concat but I know Rust deals with strings a little differently.

My code is:


    fn test2(_message: String) -> ZomeApiResult<String> 


        Ok("Hello " + _message + ", welcome to Our World!")

       // Ok("Hello, welcome to Our World!".to_string())


Obviously, this doesn’t work, so what’s the easiest way to get this working?

Any help would be really appreciated thanks. :slight_smile:

I might be slightly off here, but I think using format! would work well…

Ok(format!(“Hello {}, welcome to Our World!”, _message))

1 Like