use std::{future::Future, task::Poll};
struct A;
impl Future for &A{ // #1
type Output= ();
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
Poll::Ready(())
}
}
impl Future for * const A{ // #2
type Output= ();
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
Poll::Ready(())
}
}
#1
is permitted while #2
causes an error that
only traits defined in the current crate can be implemented for arbitrary types
*const A
is not defined in the current crate because raw pointers are always foreign
It seems that the reference to a locally defined type is considered to be a type specified in the current crate but the pointer to a locally defined type is not. What's the concrete rule for determining whether the type is considered as a type defined in the current crate?