You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following snippet, PairFoo<F>'s members are all Copy (resp. Clone) whenever F::T is Copy (resp. Clone). In spite of this, neither does #[derive(Copy)] #[derive(Clone)] work, nor can I provide my own Copy impl.
use std::marker::Copy;use std::clone::Clone;#[derive(Copy)]#[derive(Clone)]structPair<T>(pubT,pubT);traitFoo{typeT;}// #[derive(Copy)]// #[derive(Clone)]structPairFoo<F:Foo>(pubF::T,pubF::T);// this one doesn't workimpl<F,T>CopyforPairFoo<F>whereF:Foo<T = T>,T:Copy{}// this one does workimpl<F,T>CloneforPairFoo<F>whereF:Foo<T = T>,T:Clone{fnclone(&self) -> PairFoo<F>{PairFoo(self.0.clone(),self.1.clone())}}
rustc's output:
<anon>:12:1: 16:2 error: the trait `Copy` may not be implemented for this type; field `<unnamed_field>` does not implement `Copy` [E0204]
<anon>:12 impl<F, T> Copy for PairFoo<F>
<anon>:13 where F: Foo<T = T>,
<anon>:14 T: Copy
<anon>:15 {
<anon>:16 }
error: aborting due to previous error
playpen: application terminated with error code 101
The text was updated successfully, but these errors were encountered:
In the following snippet,
PairFoo<F>
's members are allCopy
(resp.Clone
) wheneverF::T
isCopy
(resp.Clone
). In spite of this, neither does#[derive(Copy)] #[derive(Clone)]
work, nor can I provide my ownCopy
impl.rustc's output:
The text was updated successfully, but these errors were encountered: