2020-08-17 01:33:30 +00:00
|
|
|
error[E0308]: mismatched types
|
2023-03-14 13:12:47 +00:00
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:2:23
|
|
|
|
|
|
|
|
|
LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i);
|
|
|
|
| -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec<i32>`, found `()`
|
|
|
|
| |
|
|
|
|
| expected due to this
|
|
|
|
|
|
|
|
|
= note: expected struct `Vec<i32>`
|
|
|
|
found unit type `()`
|
|
|
|
note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
|
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:2:71
|
|
|
|
|
|
|
|
|
LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i);
|
|
|
|
| ^^^^^^^^^^^ this call modifies its receiver in-place
|
|
|
|
|
|
|
|
error[E0599]: no method named `sort` found for unit type `()` in the current scope
|
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:3:72
|
|
|
|
|
|
|
|
|
LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
|
2023-11-10 21:00:27 +00:00
|
|
|
| ------------- --------------------- ^^^^ method not found in `()`
|
|
|
|
| | |
|
|
|
|
| | method `sort` is available on `&mut [i32]`
|
|
|
|
| method `sort` is available on `Vec<i32>`
|
2023-03-14 13:12:47 +00:00
|
|
|
|
|
|
|
|
note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
|
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:3:53
|
|
|
|
|
|
|
|
|
LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
|
|
|
|
| ^^^^^^^^^^^ this call modifies its receiver in-place
|
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:7:5
|
2020-08-17 01:33:30 +00:00
|
|
|
|
|
|
|
|
LL | fn foo(mut s: String) -> String {
|
2020-09-02 07:40:56 +00:00
|
|
|
| ------ expected `String` because of return type
|
2020-08-17 01:33:30 +00:00
|
|
|
LL | s.push_str("asdf")
|
2023-01-03 02:00:33 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^ expected `String`, found `()`
|
2020-08-17 01:33:30 +00:00
|
|
|
|
|
|
|
|
note: method `push_str` modifies its receiver in-place
|
2023-03-14 13:12:47 +00:00
|
|
|
--> $DIR/chain-method-call-mutation-in-place.rs:7:7
|
2020-08-17 01:33:30 +00:00
|
|
|
|
|
|
|
|
LL | s.push_str("asdf")
|
|
|
|
| - ^^^^^^^^ this call modifies `s` in-place
|
|
|
|
| |
|
|
|
|
| you probably want to use this value after calling the method...
|
|
|
|
= note: ...instead of the `()` output of method `push_str`
|
|
|
|
|
2023-03-14 13:12:47 +00:00
|
|
|
error: aborting due to 3 previous errors
|
2020-08-17 01:33:30 +00:00
|
|
|
|
2023-03-14 13:12:47 +00:00
|
|
|
Some errors have detailed explanations: E0308, E0599.
|
|
|
|
For more information about an error, try `rustc --explain E0308`.
|