File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ may_dangle = []
2121
2222[dependencies ]
2323serde = { version = " 1" , optional = true , default-features = false }
24+ arbitrary = { version = " 1" , optional = true }
2425
2526[dev_dependencies ]
2627bincode = " 1.0.1"
Original file line number Diff line number Diff line change 1+ use crate :: { Array , SmallVec } ;
2+ use arbitrary:: { Arbitrary , Unstructured } ;
3+
4+ impl < ' a , A : Array > Arbitrary < ' a > for SmallVec < A >
5+ where
6+ <A as Array >:: Item : Arbitrary < ' a > ,
7+ {
8+ fn arbitrary ( u : & mut Unstructured < ' a > ) -> arbitrary:: Result < Self > {
9+ u. arbitrary_iter ( ) ?. collect ( )
10+ }
11+
12+ fn arbitrary_take_rest ( u : Unstructured < ' a > ) -> arbitrary:: Result < Self > {
13+ u. arbitrary_take_rest_iter ( ) ?. collect ( )
14+ }
15+
16+ fn size_hint ( depth : usize ) -> ( usize , Option < usize > ) {
17+ arbitrary:: size_hint:: and ( <usize as Arbitrary >:: size_hint ( depth) , ( 0 , None ) )
18+ }
19+ }
Original file line number Diff line number Diff line change @@ -1651,6 +1651,9 @@ trait SpecFrom<A: Array, S> {
16511651#[ cfg( feature = "specialization" ) ]
16521652mod specialization;
16531653
1654+ #[ cfg( feature = "arbitrary" ) ]
1655+ mod arbitrary;
1656+
16541657#[ cfg( feature = "specialization" ) ]
16551658impl < ' a , A : Array > SpecFrom < A , & ' a [ A :: Item ] > for SmallVec < A >
16561659where
You can’t perform that action at this time.
0 commit comments