File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -901,8 +901,31 @@ quickcheck! {
901
901
}
902
902
903
903
quickcheck ! {
904
- fn size_combinations( it: Iter <i16 >) -> bool {
905
- correct_size_hint( it. tuple_combinations:: <( _, _) >( ) )
904
+ fn size_combinations( a: Iter <i16 >) -> bool {
905
+ let it = a. clone( ) . tuple_combinations:: <( _, _) >( ) ;
906
+ correct_size_hint( it. clone( ) ) && it. count( ) == binomial( a. count( ) , 2 )
907
+ }
908
+
909
+ fn exact_size_combinations_1( a: Vec <u8 >) -> bool {
910
+ let it = a. iter( ) . tuple_combinations:: <( _, ) >( ) ;
911
+ exact_size_for_this( it. clone( ) ) && it. count( ) == binomial( a. len( ) , 1 )
912
+ }
913
+ fn exact_size_combinations_2( a: Vec <u8 >) -> bool {
914
+ let it = a. iter( ) . tuple_combinations:: <( _, _) >( ) ;
915
+ exact_size_for_this( it. clone( ) ) && it. count( ) == binomial( a. len( ) , 2 )
916
+ }
917
+ fn exact_size_combinations_3( mut a: Vec <u8 >) -> bool {
918
+ a. truncate( 15 ) ;
919
+ let it = a. iter( ) . tuple_combinations:: <( _, _, _) >( ) ;
920
+ exact_size_for_this( it. clone( ) ) && it. count( ) == binomial( a. len( ) , 3 )
921
+ }
922
+ }
923
+
924
+ fn binomial ( n : usize , k : usize ) -> usize {
925
+ if k > n {
926
+ 0
927
+ } else {
928
+ ( n - k + 1 ..=n) . product :: < usize > ( ) / ( 1 ..=k) . product :: < usize > ( )
906
929
}
907
930
}
908
931
You can’t perform that action at this time.
0 commit comments