mirror of https://github.com/rust-lang/rust
105 lines
4.8 KiB
Plaintext
105 lines
4.8 KiB
Plaintext
error[E0631]: type mismatch in function arguments
|
|
--> $DIR/suggest-option-asderef.rs:25:52
|
|
|
|
|
LL | fn takes_str(_: &str) -> Option<()> {
|
|
| ----------------------------------- found signature defined here
|
|
...
|
|
LL | let _: Option<()> = produces_string().and_then(takes_str);
|
|
| -------- ^^^^^^^^^ expected due to this
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= note: expected function signature `fn(String) -> _`
|
|
found function signature `fn(&str) -> _`
|
|
note: required by a bound in `Option::<T>::and_then`
|
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
help: consider wrapping the function in a closure
|
|
|
|
|
LL | let _: Option<()> = produces_string().and_then(|arg0: String| takes_str(/* &str */));
|
|
| ++++++++++++++ ++++++++++++
|
|
help: call `Option::as_deref()` first
|
|
|
|
|
LL | let _: Option<()> = produces_string().as_deref().and_then(takes_str);
|
|
| +++++++++++
|
|
|
|
error[E0631]: type mismatch in function arguments
|
|
--> $DIR/suggest-option-asderef.rs:29:55
|
|
|
|
|
LL | fn takes_str(_: &str) -> Option<()> {
|
|
| ----------------------------------- found signature defined here
|
|
...
|
|
LL | let _: Option<Option<()>> = produces_string().map(takes_str);
|
|
| --- ^^^^^^^^^ expected due to this
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= note: expected function signature `fn(String) -> _`
|
|
found function signature `fn(&str) -> _`
|
|
note: required by a bound in `Option::<T>::map`
|
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
help: consider wrapping the function in a closure
|
|
|
|
|
LL | let _: Option<Option<()>> = produces_string().map(|arg0: String| takes_str(/* &str */));
|
|
| ++++++++++++++ ++++++++++++
|
|
help: call `Option::as_deref()` first
|
|
|
|
|
LL | let _: Option<Option<()>> = produces_string().as_deref().map(takes_str);
|
|
| +++++++++++
|
|
|
|
error[E0631]: type mismatch in function arguments
|
|
--> $DIR/suggest-option-asderef.rs:33:55
|
|
|
|
|
LL | fn takes_str_mut(_: &mut str) -> Option<()> {
|
|
| ------------------------------------------- found signature defined here
|
|
...
|
|
LL | let _: Option<Option<()>> = produces_string().map(takes_str_mut);
|
|
| --- ^^^^^^^^^^^^^ expected due to this
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= note: expected function signature `fn(String) -> _`
|
|
found function signature `fn(&mut str) -> _`
|
|
note: required by a bound in `Option::<T>::map`
|
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
help: consider wrapping the function in a closure
|
|
|
|
|
LL | let _: Option<Option<()>> = produces_string().map(|arg0: String| takes_str_mut(/* &mut str */));
|
|
| ++++++++++++++ ++++++++++++++++
|
|
help: call `Option::as_deref_mut()` first
|
|
|
|
|
LL | let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut);
|
|
| +++++++++++++++
|
|
|
|
error[E0631]: type mismatch in function arguments
|
|
--> $DIR/suggest-option-asderef.rs:39:40
|
|
|
|
|
LL | fn generic_ref<T>(_: &T) -> Option<()> {
|
|
| -------------------------------------- found signature defined here
|
|
...
|
|
LL | let _ = produces_string().and_then(generic_ref);
|
|
| -------- ^^^^^^^^^^^ expected due to this
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= note: expected function signature `fn(String) -> _`
|
|
found function signature `fn(&_) -> _`
|
|
note: required by a bound in `Option::<T>::and_then`
|
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
|
help: consider wrapping the function in a closure
|
|
|
|
|
LL | let _ = produces_string().and_then(|arg0: String| generic_ref(&arg0));
|
|
| ++++++++++++++ +++++++
|
|
help: consider adjusting the signature so it does not borrow its argument
|
|
|
|
|
LL - fn generic_ref<T>(_: &T) -> Option<()> {
|
|
LL + fn generic_ref<T>(_: T) -> Option<()> {
|
|
|
|
|
help: call `Option::as_deref()` first
|
|
|
|
|
LL | let _ = produces_string().as_deref().and_then(generic_ref);
|
|
| +++++++++++
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0631`.
|