error[E0307]: invalid `self` parameter type: `Xxxx`
self の型に許可されない型を使用した。
『組込型の特権/self への型指定』によると、self に許される型は、実装対象それ以外では、一部の組込型のみである。
以下では、型 MyType の実装中に self の型に i32 を指定している。
fn main() {}
struct MyType();
impl MyType {
fn method(self: i32) {
// nop.
}
}
error[E0307]: invalid `self` parameter type: `i32`
--> src/main.rs:5:21
|
5 | fn method(self: i32) {
| ^^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)