]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0369.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0369.md
1 A binary operation was attempted on a type which doesn't support it.
2
3 Erroneous code example:
4
5 ```compile_fail,E0369
6 let x = 12f32; // error: binary operation `<<` cannot be applied to
7                //        type `f32`
8
9 x << 2;
10 ```
11
12 To fix this error, please check that this type implements this binary
13 operation. Example:
14
15 ```
16 let x = 12u32; // the `u32` type does implement it:
17                // https://doc.rust-lang.org/stable/std/ops/trait.Shl.html
18
19 x << 2; // ok!
20 ```
21
22 It is also possible to overload most operators for your own type by
23 implementing traits from `std::ops`.
24
25 String concatenation appends the string on the right to the string on the
26 left and may require reallocation. This requires ownership of the string
27 on the left. If something should be added to a string literal, move the
28 literal to the heap by allocating it with `to_owned()` like in
29 `"Your text".to_owned()`.