좋아, 이제 막 조금 녹이기 시작하고 꽤 간단한 문제를 겪고 있습니다. 이 같은 재귀 유형이 : 나는재귀 유형 및 배열
hex.rs:30:29: 30:40 error: the trait `core::marker::Copy` is not implemented for the type `Tree` [E0277]
hex.rs:30 children : Box::new([None; 100])
^~~~~~~~~~~
error: aborting due to previous error
그래서 트리를 초기화하는 때, 나는 구조체 정의 전에
#[derive(Copy)]
을 추가
나중에struct Tree {
root : i32,
children : Box<[Option<Tree> ; 100]>
}
을,하지만 난 있어요 이 오류 :
hex.rs:8:10: 8:14 error: the trait `Copy` may not be implemented for this type; field `children` does not implement `Copy` [E0204]
hex.rs:8 #[derive(Copy)]
^~~~
note: in expansion of #[derive]
hex.rs:8:1: 8:16 note: expansion site
error: aborting due to previous error
여기에서 어디로 가야할지 모르겠습니다. 재귀 적 데이터 유형에 대한 특성을 파생시키는 쉬운 방법이 있습니까?
처럼 보일 수 그것은 ['단지 아무도 없다; 100]'너는 쓸 수 없다. '[없음, 없음, 없음, 없음, ...]'괜찮습니다. 그러나 의미 론적으로 나는'Vec'이 당신이 원하는 것을 더 많이 상상한다. –
맞아, 그걸 시도해 보니 효과가 있었지만, 여러 가지 이유로 그 느낌이 틀렸다. Vec은 내가 필요한 것에 적합합니다. –
Emil