Advice to change function signature when aliases are involved
Here’s a scenario from earlier in this guide. The compiler advice is:
error[E0621]: explicit lifetime required in the type of `s`
--> src/lib.rs:5:9
|
5 | Self(s)
| ^^^^^^^ lifetime `'a` required
|
help: add explicit lifetime `'a` to the type of `s`
|
4 | fn new(s: &'a str) -> Node<'_> {
| ++
- Self(s)
+ Node(s)
And you may even get the above compiler advice when implementing a trait, where you usually can’t change the signature.