このコード (プレイ中も)
use std::sync::Arc;
struct Foo {
x: isize, // Something complex in actual code, implements Drop
}
#[derive(Clone)]
struct Good {
a: Option<Arc<Foo>>,
b: Option<Arc<Foo>>,
c: Option<Arc<Foo>>,
}
#[derive(Clone)]
struct Bad {
x: [Option<Arc<Foo>>; 3],
}
fn main() {
println!("See?");
}
で失敗しBad
ます
<anon>:16:5: 16:29 error: the trait `core::marker::Copy` is not implemented for the type `alloc::arc::Arc<Foo>` [E0277]
<anon>:16 x: [Option<Arc<Foo>>; 3],
^~~~~~~~~~~~~~~~~~~~~~~~
<anon>:14:10: 14:15 note: in expansion of #[derive_Clone]
しかし、それは問題ありませんGood
。
- これはなぜかと、
- 回避策はありますか?私は、12 の独立したフィールドを扱うことにまったく熱心ではありません。