File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,16 @@ pub struct TreeIterator {
45
45
flags : TreeFlags ,
46
46
}
47
47
48
+ impl FromIterator < NonOwningTree > for Vec < Tree > {
49
+ fn from_iter < T : IntoIterator < Item = NonOwningTree > > ( iter : T ) -> Self {
50
+ let mut out = vec ! [ ] ;
51
+ for i in iter {
52
+ unimplemented ! ( "not yet!" ) ;
53
+ }
54
+ out
55
+ }
56
+ }
57
+
48
58
impl TreeIterator {
49
59
// FIXME: init if fallible!
50
60
fn new ( treeseq : & TreeSequence ) -> Self {
@@ -755,10 +765,9 @@ pub(crate) mod test_trees {
755
765
// This is a safety sticking point:
756
766
// we cannot collect the iterable itself b/c
757
767
// the underlying tree memory is re-used.
758
- let v = treeseq
759
- . trees ( )
760
- . map ( |t| t. as_owned ( ) ) // this is what we mean, but this is broken
761
- . collect :: < Vec < NonOwningTree > > ( ) ;
768
+ let i = treeseq
769
+ . trees ( ) ;
770
+ let v = Vec :: < Tree > :: from_iter ( i) ;
762
771
assert_eq ! ( v. len( ) , 2 ) ;
763
772
}
764
773
You can’t perform that action at this time.
0 commit comments