File: suggest-option-asderef.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (104 lines) | stat: -rw-r--r-- 4,901 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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`.