#E0078: 허용되지 않는 impl
이 impl은 허용되지 않습니다. 타입 매개변수에 대한 고유 impl, Reflect의 수동 impl, 자동 트레잇(Send, Sync)도 unsafe trait도 아닌 트레잇의 unsafe impl, 자동 트레잇이 아닌 트레잇의 impl !Trait, unsafe trait의 평범한 impl이 그렇습니다. 지우거나 메시지가 알려 주는 형태로 쓰세요.
nabi
struct X { n: i32; }
impl Send for X {}
error[E0078]: `Send` is an auto trait the compiler derives from the fields; a manual impl for `X` must be `unsafe impl Send for X {}` --> main.nabi:2:1 | 2 | impl Send for X {} | ^^^^
Send와 Sync는 필드에서 오므로, 필드가 모두 Send인 타입은 impl 없이도 Send입니다.
nabi
struct X { n: i32; }
fn needs_send<T: Send>(x: T) -> T { x }
println(f"{needs_send(X { n: 1 }).n}");
1
관련 코드: E0076 외부 타입에 대한 외부 트레잇의 impl, E0085 스레드를 넘을 수 없는 값
잘못된 곳이 있나요? GitHub에서 이 페이지 고치기. 마지막 수정