1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
// #![ cfg_attr( feature = "no_std", no_std ) ]
//! # Important: `vec!` Macro Ambiguity
//!
//! When using `use test_tools::*`, you may encounter ambiguity between `std::vec!` and `collection_tools::vec!`.
//!
//! ## Solutions :
//!
//! ```rust
//! // RECOMMENDED: Use std::vec! explicitly
//! use test_tools::*;
//! let v = std::vec![1, 2, 3];
//!
//! // OR: Use selective imports
//! use test_tools::{ BTreeMap, HashMap };
//! let v = vec![1, 2, 3]; // No ambiguity
//!
//! // OR: Use collection macros explicitly
//! let collection_vec = collection_tools::vector_from![1, 2, 3];
//! ```
//!
//! # API Stability Facade
//!
//! This crate implements a comprehensive API stability facade pattern (FR-3) that shields
//! users from breaking changes in underlying constituent crates. The facade ensures :
//!
//! - **Stable API Surface** : Core functionality remains consistent across versions
//! - **Namespace Isolation** : Changes in constituent crates don't affect public namespaces
//! - **Dependency Insulation** : Internal dependency changes are hidden from users
//! - **Backward Compatibility** : Existing user code continues to work across updates
//!
//! ## Stability Mechanisms
//!
//! ### 1. Controlled Re-exports
//! All types and functions from constituent crates are re-exported through carefully
//! controlled namespace modules (own, orphan, exposed, prelude) that maintain consistent APIs.
//!
//! ### 2. Dependency Isolation Module
//! The `dependency` module provides controlled access to underlying crates, allowing
//! updates to constituent crates without breaking the public API.
//!
//! ### 3. Feature-Stable Functionality
//! Core functionality works regardless of feature combinations, with optional features
//! providing enhanced capabilities without breaking the base API.
//!
//! # Test Compilation Troubleshooting Guide
//!
//! This crate aggregates testing tools from multiple ecosystem crates. Due to the complexity
//! of feature propagation and macro re-exports, test compilation can fail in specific patterns.
//!
//! ## Quick Diagnosis Commands
//!
//! ```bash
//! # Test compilation (fastest diagnostic)
//! cargo test -p test_tools --all-features --no-run
//!
//! # Full test suite
//! cargo test -p test_tools --all-features
//!
//! # Verbose compilation for detailed errors
//! cargo test -p test_tools --all-features --no-run -v
//! ```
//!
//! ## Common Error Patterns & Solutions
//!
//! ### E0432 Errors (API Visibility)
//! ```text
//! error[E0432]: unresolved imports `test_tools::tests_impls`, `test_tools::exposed`
//! ```
//! **Root Cause: ** Public API modules hidden by cfg gates
//! **Solution: ** Remove `#[ cfg(not(feature = "doctest")) ]` gates on namespace modules
//! **Prevention: ** See warnings in namespace module documentation below
//!
//! ### E0433 Errors (Macro Resolution)
//! ```text
//! error[E0433]: failed to resolve: could not find `heap` in `the_module`
//! ```
//! **Root Cause: ** Collection constructor macros not re-exported
//! **Solution: ** Verify macro re-exports around line 160-180 in this file
//! **Quick Fix: ** Ensure explicit macro re-exports with proper feature gates
//!
//! ## Step-by-Step Debugging Process
//!
//! 1. **Count errors by type: ** `cargo test -p test_tools --all-features --no-run 2>&1 | grep "error\[" | sort | uniq -c`
//! 2. **For E0432 (API visibility) : ** Check namespace modules for doctest cfg gates
//! 3. **For E0433 (macro resolution) : ** Check macro re-exports and feature configuration
//! 4. **Verify feature propagation: ** Check with `-v` flag for enabled features
//!
//! ## Historical Context
//! - **Task 001 : ** Fixed 147 E0432 errors by removing doctest cfg gates from API modules
//! - **Task 002 : ** Fixed 7 E0433 errors by adding explicit macro re-exports
//! - **Task 003 : ** Added this embedded documentation to prevent regressions
//!
/// Namespace with dependencies.
/// Behavioral equivalence verification framework for re-exported utilities.
/// Aggregating submodules without using cargo, but including their entry files directly.
///
/// We don't want to run doctest of included files, because all of the are relative to submodule.
/// So we disable doctests of such submodules with `#[ cfg( not( doctest ) ) ]`.
// #[ cfg( all( feature = "no_std", feature = "use_alloc" ) ) ]
// #[ cfg( any( not( doctest ), not( feature = "standalone_build" ) ) ) ]
// Use selective exports instead of glob to avoid conflicts
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(feature = "standalone_build") ]
// #[ allow(hidden_glob_reexports) ]
// pub use standalone :: *;
// Re-export essential functions and types from standalone module
// Available in all modes to ensure test compatibility
pub use standalone :: ;
// Re-export impls_index modules for direct root access
pub use ;
// Diagnostics macros are now defined directly in the standalone module
// Add error module for compatibility with error_tools tests
/// Error handling module for `error_tools` compatibility in standalone mode
// tests_impls and tests_index already imported above
// Re-export collection_tools as a module for compatibility
pub use collection_tools;
// Re-export diagnostics_tools as a module for compatibility
pub use diagnostics_tools;
/// Error tools module for external crate compatibility
///
/// This module provides error handling utilities and types for standalone build mode.
/// It re-exports functionality from the standalone `error_tools` implementation.
/// Memory tools module for external crate compatibility
///
/// This module provides memory comparison utilities for standalone build mode.
/// Vector module for external crate compatibility
///
/// This module provides Vec iterator types for standalone build mode.
/// Collection module for external crate compatibility
///
/// This module provides collection utilities for standalone build mode.
// COMMENTED OUT: Normal build dependencies disabled to break circular dependencies
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// pub use :: { error_tools, impls_index, mem_tools, typing_tools, diagnostics_tools };
// // Re-export key mem_tools functions at root level for easy access
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// pub use mem_tools :: { same_data, same_ptr, same_size, same_region };
// // Re-export error handling utilities at root level for easy access
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "error_untyped" ) ]
// pub use error_tools :: { anyhow as error, bail, ensure, format_err };
// Import process module
pub use process;
// COMMENTED OUT: collection_tools dependency disabled to break circular dependencies
// /// Re-export `collection_tools` types and functions but not macros to avoid ambiguity.
// /// Macros are available via `collection_tools ::macro_name`! to prevent `std ::vec`! conflicts.
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// pub use collection_tools :: {
// // Collection types
// BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque, Vec,
// // Collection modules
// collection, btree_map, btree_set, binary_heap, hash_map, hash_set, linked_list, vec_deque, vector,
// };
// COMMENTED OUT: collection_tools macros disabled to break circular dependencies
// // Re-export collection macros at root level with original names for aggregated tests
// // This will cause ambiguity with std ::vec! when using wildcard imports
// // NOTE: vec! macro removed to prevent ambiguity with std ::vec!
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "collection_constructors" ) ]
// pub use collection_tools :: { heap, bmap, bset, hmap, hset, llist, deque, dlist };
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "collection_into_constructors" ) ]
// pub use collection_tools :: { into_heap, into_vec, into_bmap, into_bset, into_hmap, into_hset, into_llist, into_vecd, into_dlist };
/// Collection constructor macros moved to prelude module to prevent ambiguity.
///
/// # CRITICAL REGRESSION PREVENTION
///
/// ## Why Moved to Prelude
/// Collection constructor macros like `heap!`, `vec!`, etc. were previously re-exported
/// at crate root level, causing ambiguity with `std ::vec`! when using `use test_tools :: *`.
///
/// Moving them to prelude resolves the ambiguity while maintaining access via
/// `use test_tools ::prelude :: *` for users who need collection constructors.
///
/// ## What Happens If Moved Back to Root
/// Re-exporting at root will cause E0659 ambiguity errors :
/// ```text
/// error[E0659] : `vec` is ambiguous
/// = note: `vec` could refer to a macro from prelude
/// = note: `vec` could also refer to the macro imported here
/// ```
///
/// ## Access Patterns
/// - Standard tests: `use test_tools :: *;` (no conflicts)
/// - Collection macros needed: `use test_tools ::prelude :: *;`
/// - Explicit access: `test_tools ::prelude ::vec![]`
///
/// ## Historical Context
/// This resolves the vec! ambiguity issue while preserving Task 002's macro accessibility.
pub use :: ;
// COMMENTED OUT: error_tools dependency disabled to break circular dependencies
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// pub use error_tools ::error;
// // Re-export error! macro as anyhow! from error_tools
// COMMENTED OUT: implsindex dependency disabled to break circular dependencies
// #[ cfg( feature = "enabled" ) ]
// #[ cfg(all(feature = "standalone_build", not(feature = "normal_build"))) ]
// pub use implsindex as impls_index;
pub use :: ;
/// Verifies that the API stability facade is functioning correctly.
/// This function can be used to check that all stability mechanisms are operational.
pub use *;
/// vec! macro removed to prevent ambiguity with `std ::vec`!
/// Aggregated `collection_tools` tests will need to use `collection_tools ::vec`! explicitly
/// Own namespace of the module.
///
/// # CRITICAL REGRESSION PREVENTION WARNING
///
/// DO NOT add `#[ cfg(not(feature = "doctest")) ]` gates to this module or any of the
/// namespace modules (own, orphan, exposed, prelude). This will hide the public API
/// from tests when the doctest feature is enabled, causing widespread compilation failures.
///
/// ## Historical Context
/// Task 001 resolved 147 compilation errors caused by such gates hiding the API.
/// The pattern `#[ cfg(not(feature = "doctest")) ]` broke test compilation because :
/// 1. Test runner enables doctest feature via rustdocflags in .cargo/config.toml
/// 2. This caused the cfg condition to be true, hiding the modules
/// 3. Aggregated tests could no longer import from `the_module ::exposed :: *` etc.
///
/// ## Safe Alternative
/// Use feature-specific functionality inside modules, but keep module structure visible.
/// Never hide entire namespace modules with doctest-related cfg gates.
///
/// Shared with parent namespace of the module
///
/// # REGRESSION PREVENTION: Keep this module always visible to tests
/// Same warning as `own` module applies here. See documentation above.
/// Exposed namespace of the module.
///
/// # REGRESSION PREVENTION: Keep this module always visible to tests
/// This is the primary module accessed by aggregated tests via `the_module ::exposed :: *`.
/// Hiding this with doctest cfg gates will break all aggregated test imports.
;
}
/// Placeholder macro for impls2 (implementation compatibility in standalone mode)
)*
};
}
/// Placeholder macro for impls3 (implementation compatibility in standalone mode)
)*
};
}
pub use impls1;
pub use impls2;
// Re-export test function macros for impls_index compatibility
pub use super :: ;
// Create actual functions for impls2 test compatibility (f1b, f2b)
/// Function alias f1b for impls2 test compatibility
/// Function alias f2b for impls2 test compatibility
// Add missing "into" collection constructor macros
/// Placeholder macro for `into_bmap` (collection compatibility in standalone mode)
/// Placeholder macro for `into_bset` (collection compatibility in standalone mode)
/// Placeholder macro for `into_vec` (collection compatibility in standalone mode)
// into collection macros already exported in exposed module above
// Type aliases for collection compatibility
/// Type alias for `LinkedList` for backward compatibility
pub type Llist< T > = LinkedList;
/// Type alias for `HashMap` for backward compatibility
pub type Hmap< K, V > = HashMap;
/// Type alias for `BTreeMap` for backward compatibility
pub type Bmap< K, V > = ;
/// Type alias for `BTreeSet` for backward compatibility
pub type Bset< T > = ;
/// Type alias for `HashSet` for backward compatibility
pub type Hset< T > = ;
/// Type alias for `HashMap` for backward compatibility (Map)
pub type Map< K, V > = ;
/// Type alias for `HashSet` for backward compatibility (Set)
pub type Set< T > = ;
// COMMENTED OUT: Dependencies disabled to break circular dependencies
// #[ doc( inline ) ]
// pub use {
// error_tools :: {debug_assert_id, debug_assert_identical, debug_assert_ni, debug_assert_not_identical, ErrWith},
// impls_index ::exposed :: *,
// mem_tools ::exposed :: *, // This includes same_data, same_ptr, same_size, same_region
// typing_tools ::exposed :: *,
// diagnostics_tools ::exposed :: *,
// };
// // Re-export error handling macros from error_tools for comprehensive access
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "error_untyped" ) ]
// #[ doc( inline ) ]
// pub use error_tools :: { anyhow as error, bail, ensure, format_err };
// COMMENTED OUT: collection_tools dependency disabled to break circular dependencies
// // Re-export collection_tools types and macros for exposed namespace
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ doc( inline ) ]
// pub use collection_tools :: {
// BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque, Vec,
// collection, btree_map, btree_set, binary_heap, hash_map, hash_set, linked_list, vec_deque, vector,
// };
// // Re-export collection type aliases from collection ::exposed
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ doc( inline ) ]
// pub use collection_tools ::collection ::exposed :: {
// Llist, Dlist, Deque, Map, Hmap, Set, Hset, Bmap, Bset,
// };
// // Collection constructor macros for aggregated test compatibility
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "collection_constructors" ) ]
// pub use collection_tools :: { heap, bmap, bset, hmap, hset, llist, deque, dlist };
// #[ cfg(not(all(feature = "standalone_build", not(feature = "normal_build")))) ]
// #[ cfg( feature = "collection_into_constructors" ) ]
// pub use collection_tools :: { into_heap, into_vec, into_bmap, into_bset, into_hmap, into_hset, into_llist, into_vecd, into_dlist };
}
/// Prelude to use essentials: `use my_module::prelude::*`.
///
/// # REGRESSION PREVENTION: Keep this module always visible to tests
/// Same warning as other namespace modules. Never hide with doctest cfg gates.