3 ms·
fn main() { let a = "Hello,"; let b = " world."; let c = a + b; println!("{}", c); } And the result is: rustc 1.15.0-beta.3 (
by EdiX 10y ago
fn main() {
let a = "Hello,";
let b = " world.";
let c = a + b;
println!("{}", c);
}
And the result is:
rustc 1.15.0-beta.3 (a035041ba 2017-01-07)
error[E0369]: binary operation `+` cannot be applied to type `&str`
|
5 | let c = a + b; // this is the only part that concats, really.
| ^
|
note: an implementation of `std::ops::Add` might be missing for `&str`
|
5 | let c = a + b; // this is the only part that concats, really.
| ^
timeout triggered!
What?
PS. looks like hacker news can't handle rustc error format, a pity...
- okey 10y agoAs the post you are responding to pointed out, String::from converts from a string slice to a String. You didn't do this. Your code fails to compile because it attempts to apply + to two string slices, and that is not implemented. @deathanatos also mentioned that. You might find the Rust book page on Strings helpful: https://doc.rust-lang.org/book/strings.html https://doc.rust-lang.org/book/strings.html