File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1004,6 +1004,31 @@ fn test_append_permutations() {
1004
1004
}
1005
1005
}
1006
1006
1007
+ struct DropCounter < ' a > {
1008
+ count : & ' a mut u32 ,
1009
+ }
1010
+
1011
+ impl < ' a > Drop for DropCounter < ' a > {
1012
+ fn drop ( & mut self ) {
1013
+ * self . count += 1 ;
1014
+ }
1015
+ }
1016
+
1017
+ #[ test]
1018
+ fn test_append_double_drop ( ) {
1019
+ let ( mut count_a, mut count_b) = ( 0 , 0 ) ;
1020
+ {
1021
+ let mut a = VecDeque :: new ( ) ;
1022
+ let mut b = VecDeque :: new ( ) ;
1023
+ a. push_back ( DropCounter { count : & mut count_a } ) ;
1024
+ b. push_back ( DropCounter { count : & mut count_b } ) ;
1025
+
1026
+ a. append ( & mut b) ;
1027
+ }
1028
+ assert_eq ! ( count_a, 1 ) ;
1029
+ assert_eq ! ( count_b, 1 ) ;
1030
+ }
1031
+
1007
1032
#[ test]
1008
1033
fn test_retain ( ) {
1009
1034
let mut buf = VecDeque :: new ( ) ;
You can’t perform that action at this time.
0 commit comments