When trying to call a method on a raw pointer Rust compiler says there's no such method.
It would be better to say that there is such method, but the pointer has to be explicitly dereferenced first.
let x = 8u8;
let y = &x;
let z: *const u8 = &x;
println!("{} {}",
y.to_string(), // OK
z.to_string() // Not OK
);
error: type *const u8 does not implement any method in scope named to_string
This is technically correct, but unexpected and help hint for this error suggests wrong solution.
I've read this message as "yada yada no such method", so I went to check whether I've spelled the method correctly, whether I've put the method in the appropriate impl block, etc. — all completely irrelevant to this error.
I'd find something like that more helpful:
error: method to_string requires type u8, but *const u8 cannot be automatically dereferenced. hint: use as_ref()
When trying to call a method on a raw pointer Rust compiler says there's no such method.
It would be better to say that there is such method, but the pointer has to be explicitly dereferenced first.
This is technically correct, but unexpected and help hint for this error suggests wrong solution.
I've read this message as "yada yada no such method", so I went to check whether I've spelled the method correctly, whether I've put the method in the appropriate
implblock, etc. — all completely irrelevant to this error.I'd find something like that more helpful: