base_traits/traits/
is_empty.rs

1// src/traits/is_empty.rs : `IsEmpty`
2
3/// Trait defining instance method `is_empty() : bool` that indicates
4/// whether the implementing type instance is logically empty.
5///
6/// # Additional Implementations on Foreign Types
7///
8/// ## Built-in Types
9///
10/// If the feature `"implement-IsEmpty-for-built_ins"`
11/// is defined (as it is by `"default"`), then this is also implemented
12/// for the following types:
13/// - [`str`];
14/// - `[T; N]`;
15/// - `[T]`;
16///
17/// ## Standard Collection Types
18///
19/// If the feature `"implement-IsEmpty-for-standard_collection_types"`
20/// is defined (as it is by `"default"`), then this is also implemented
21/// for the following types:
22/// - [`std::collections::BTreeMap`];
23/// - [`std::collections::BTreeSet`];
24/// - [`std::collections::BinaryHeap`];
25/// - [`std::collections::HashMap`];
26/// - [`std::collections::HashSet`];
27/// - [`std::collections::LinkedList`];
28/// - [`String`];
29/// - [`Vec`];
30/// - [`std::collections::VecDeque`];
31///
32/// ## Standard FFI Types
33///
34/// If the feature `"implement-IsEmpty-for-standard_ffi_types"`
35/// is defined (as it is by `"default"`), then this is also implemented
36/// for the following types:
37/// - [`std::ffi::CStr`];
38/// - [`std::ffi::CString`];
39///
40/// ## Standard Path Types
41///
42/// If the feature `"implement-IsEmpty-for-standard_path_types"`
43/// is defined (as it is by `"default"`), then this is also implemented
44/// for the following types:
45/// - [`std::path::Path`];
46/// - [`std::path::PathBuf`];
47///
48/// ## Standard Process Types
49///
50/// If the feature `"implement-IsEmpty-for-standard_process_types"`
51/// is defined (as it is by `"default"`), then this is also implemented
52/// for the following types:
53/// - [`std::process::CommandArgs`];
54/// - [`std::process::CommandEnvs`];
55///
56/// ## Standard Range Types
57///
58/// If the feature `"implement-IsEmpty-for-standard_range_types"`
59/// is defined (as it is by `"default"`), then this is also implemented
60/// for the following types:
61/// - [`std::ops::Range`];
62/// - [`std::ops::RangeFrom`];
63/// - [`std::ops::RangeFull`];
64/// - [`std::ops::RangeInclusive`];
65/// - [`std::ops::RangeTo`];
66///
67/// ## Standard Time Types
68///
69/// If the feature `"implement-IsEmpty-for-standard_time_types"`
70/// is defined (which is NOT by `"default"`), then this is also implemented
71/// for the following types:
72/// - [`std::time::Duration`];
73pub trait IsEmpty {
74    fn is_empty(&self) -> bool;
75}
76
77
78#[cfg(all(not(test), not(feature = "nostd")))]
79impl<T : IsEmpty + ?Sized> IsEmpty for Box<T> {
80    fn is_empty(&self) -> bool {
81        (**self).is_empty()
82    }
83}
84
85#[cfg(all(not(test), not(feature = "nostd")))]
86impl<T : IsEmpty + ?Sized> IsEmpty for std::rc::Rc<T> {
87    fn is_empty(&self) -> bool {
88        (**self).is_empty()
89    }
90}
91
92
93#[cfg(feature = "implement-IsEmpty-for-built_ins")]
94mod impl_for_built_ins {
95
96
97    mod isolate_ {
98        #![allow(non_snake_case)]
99
100
101        #[inline]
102        pub(super) fn get_is_empty_str_(s : &str) -> bool {
103            s.is_empty()
104        }
105
106        #[inline]
107        pub(super) fn get_is_empty_Slice_<T>(s : &[T]) -> bool {
108            s.is_empty()
109        }
110    }
111
112
113    // str
114
115    impl super::IsEmpty for str {
116        #[inline]
117        fn is_empty(&self) -> bool {
118            isolate_::get_is_empty_str_(self)
119        }
120    }
121
122    impl super::IsEmpty for &str {
123        #[inline]
124        fn is_empty(&self) -> bool {
125            isolate_::get_is_empty_str_(self)
126        }
127    }
128
129    // Array
130
131    impl<T, const N: usize> super::IsEmpty for [T; N] {
132        #[inline]
133        fn is_empty(&self) -> bool {
134            0 == N
135        }
136    }
137
138    impl<T, const N: usize> super::IsEmpty for &[T; N] {
139        #[inline]
140        fn is_empty(&self) -> bool {
141            0 == N
142        }
143    }
144
145    // Slice
146
147    impl<T> super::IsEmpty for [T] {
148        #[inline]
149        fn is_empty(&self) -> bool {
150            isolate_::get_is_empty_Slice_(self)
151        }
152    }
153
154    impl<T> super::IsEmpty for &[T] {
155        #[inline]
156        fn is_empty(&self) -> bool {
157            isolate_::get_is_empty_Slice_(self)
158        }
159    }
160}
161
162
163#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_collection_types"))]
164mod impl_for_std_coll_types {
165    use std::collections as std_collections;
166
167
168    mod isolate_ {
169        #![allow(non_snake_case)]
170
171        use std::collections as std_collections;
172
173
174        #[inline]
175        pub(super) fn get_is_empty_BTreeMap_<K, V>(coll : &std_collections::BTreeMap<K, V>) -> bool {
176            coll.is_empty()
177        }
178
179        #[inline]
180        pub(super) fn get_is_empty_BTreeSet_<T>(coll : &std_collections::BTreeSet<T>) -> bool {
181            coll.is_empty()
182        }
183
184        #[inline]
185        pub(super) fn get_is_empty_BinaryHeap_<T>(coll : &std_collections::BinaryHeap<T>) -> bool {
186            coll.is_empty()
187        }
188
189        #[inline]
190        pub(super) fn get_is_empty_HashMap_<K, V>(coll : &std_collections::HashMap<K, V>) -> bool {
191            coll.is_empty()
192        }
193
194        #[inline]
195        pub(super) fn get_is_empty_HashSet_<T>(coll : &std_collections::HashSet<T>) -> bool {
196            coll.is_empty()
197        }
198
199        #[inline]
200        pub(super) fn get_is_empty_LinkedList_<T>(coll : &std_collections::LinkedList<T>) -> bool {
201            coll.is_empty()
202        }
203
204        // NOTE: parameter type is `&str`, not `&String`
205        #[inline]
206        pub(super) fn get_is_empty_String_(s : &str) -> bool {
207            s.is_empty()
208        }
209
210        // NOTE: parameter type is `&[T]`, not `&Vec<T>`
211        #[inline]
212        pub(super) fn get_is_empty_Vec_<T>(coll : &[T]) -> bool {
213            coll.is_empty()
214        }
215
216        #[inline]
217        pub(super) fn get_is_empty_VecDeque_<T>(coll : &std_collections::VecDeque<T>) -> bool {
218            coll.is_empty()
219        }
220    }
221
222
223    // BTreeMap<>
224
225    impl<K, V> super::IsEmpty for std_collections::BTreeMap<K, V> {
226        #[inline]
227        fn is_empty(&self) -> bool {
228            isolate_::get_is_empty_BTreeMap_(self)
229        }
230    }
231
232    // BTreeSet<>
233
234    impl<T> super::IsEmpty for std_collections::BTreeSet<T> {
235        #[inline]
236        fn is_empty(&self) -> bool {
237            isolate_::get_is_empty_BTreeSet_(self)
238        }
239    }
240
241    // BinaryHeap<>
242
243    impl<T> super::IsEmpty for std_collections::BinaryHeap<T> {
244        #[inline]
245        fn is_empty(&self) -> bool {
246            isolate_::get_is_empty_BinaryHeap_(self)
247        }
248    }
249
250    // HashMap<>
251
252    impl<K, V> super::IsEmpty for std_collections::HashMap<K, V> {
253        #[inline]
254        fn is_empty(&self) -> bool {
255            isolate_::get_is_empty_HashMap_(self)
256        }
257    }
258
259    // HashSet<>
260
261    impl<T> super::IsEmpty for std_collections::HashSet<T> {
262        #[inline]
263        fn is_empty(&self) -> bool {
264            isolate_::get_is_empty_HashSet_(self)
265        }
266    }
267
268    // LinkedList<>
269
270    impl<T> super::IsEmpty for std_collections::LinkedList<T> {
271        #[inline]
272        fn is_empty(&self) -> bool {
273            isolate_::get_is_empty_LinkedList_(self)
274        }
275    }
276
277    // String
278
279    impl super::IsEmpty for String {
280        #[inline]
281        fn is_empty(&self) -> bool {
282            isolate_::get_is_empty_String_(self)
283        }
284    }
285
286    // Vec<>
287
288    impl<T> super::IsEmpty for Vec<T> {
289        #[inline]
290        fn is_empty(&self) -> bool {
291            isolate_::get_is_empty_Vec_(self)
292        }
293    }
294
295    // VecDeque<>
296
297    impl<T> super::IsEmpty for std_collections::VecDeque<T> {
298        #[inline]
299        fn is_empty(&self) -> bool {
300            isolate_::get_is_empty_VecDeque_(self)
301        }
302    }
303}
304
305
306#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_ffi_types"))]
307mod impl_for_std_ffi_types {
308    #![allow(non_snake_case)]
309
310    use std::ffi as std_ffi;
311
312
313    mod isolate_ {
314        #![allow(non_snake_case)]
315
316        use std::ffi as std_ffi;
317
318
319        #[inline]
320        pub(super) fn get_is_empty_CStr_(cstr : &std_ffi::CStr) -> bool {
321            cstr.is_empty()
322        }
323
324        #[inline]
325        pub(super) fn get_is_empty_CString_(cstring : &std_ffi::CString) -> bool {
326            cstring.is_empty()
327        }
328    }
329
330
331    // CStr
332
333    impl super::IsEmpty for std_ffi::CStr {
334        #[inline]
335        fn is_empty(&self) -> bool {
336            isolate_::get_is_empty_CStr_(self)
337        }
338    }
339
340    impl super::IsEmpty for &std_ffi::CStr {
341        #[inline]
342        fn is_empty(&self) -> bool {
343            isolate_::get_is_empty_CStr_(self)
344        }
345    }
346
347    // CString
348
349    impl super::IsEmpty for std_ffi::CString {
350        #[inline]
351        fn is_empty(&self) -> bool {
352            isolate_::get_is_empty_CString_(self)
353        }
354    }
355}
356
357
358#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_path_types"))]
359mod impl_for_std_path_types {
360    use std::path as std_path;
361
362
363    // Path
364
365    impl super::IsEmpty for &std_path::Path {
366        fn is_empty(&self) -> bool {
367            self.as_os_str().is_empty()
368        }
369    }
370
371    // PathBuf
372
373    impl super::IsEmpty for std_path::PathBuf {
374        fn is_empty(&self) -> bool {
375            self.as_os_str().is_empty()
376        }
377    }
378
379    impl super::IsEmpty for &std_path::PathBuf {
380        fn is_empty(&self) -> bool {
381            self.as_os_str().is_empty()
382        }
383    }
384}
385
386
387#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_process_types"))]
388mod impl_for_std_process_types {
389    #![allow(non_snake_case)]
390
391    #[cfg(feature = "experimental-exact_size_is_empty")]
392    use std::process as std_process;
393
394
395    mod isolate_ {
396        #![allow(non_snake_case)]
397
398        #[cfg(feature = "experimental-exact_size_is_empty")]
399        use std::process as std_process;
400
401
402        #[cfg(feature = "experimental-exact_size_is_empty")]
403        #[inline]
404        pub(super) fn get_is_empty_CommandArgs_<'a>(ca : &std_process::CommandArgs<'a>) -> bool {
405            ca.is_empty()
406        }
407
408        #[cfg(feature = "experimental-exact_size_is_empty")]
409        #[inline]
410        pub(super) fn get_is_empty_CommandEnvs_<'a>(ce : &std_process::CommandEnvs<'a>) -> bool {
411            ce.is_empty()
412        }
413    }
414
415
416    // CommandArgs<'>
417
418    #[cfg(feature = "experimental-exact_size_is_empty")]
419    impl<'a> super::IsEmpty for &std_process::CommandArgs<'a> {
420        fn is_empty(&self) -> bool {
421            isolate_::get_is_empty_CommandArgs_(self)
422        }
423    }
424
425    // CommandEnvs<'>
426
427    #[cfg(feature = "experimental-exact_size_is_empty")]
428    impl<'a> super::IsEmpty for &std_process::CommandEnvs<'a> {
429        fn is_empty(&self) -> bool {
430            isolate_::get_is_empty_CommandEnvs_(self)
431        }
432    }
433}
434
435
436#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_range_types"))]
437mod impl_for_std_range_types {
438    #![allow(non_snake_case)]
439
440    use std::{
441        cmp as std_cmp,
442        ops as std_ops,
443    };
444
445
446    mod isolate_ {
447        use std::{
448            cmp as std_cmp,
449            ops as std_ops,
450        };
451
452
453        #[inline]
454        pub(super) fn get_is_empty_Range_<Idx : std_cmp::PartialOrd>(r : &std_ops::Range<Idx>) -> bool {
455            r.is_empty()
456        }
457
458        #[inline]
459        pub(super) fn get_is_empty_RangeInclusive_<Idx : std_cmp::PartialOrd>(r : &std_ops::RangeInclusive<Idx>) -> bool {
460            r.is_empty()
461        }
462    }
463
464
465    // Range<>
466
467    impl<Idx : std_cmp::PartialOrd> super::IsEmpty for std_ops::Range<Idx> {
468        #[inline]
469        fn is_empty(&self) -> bool {
470            isolate_::get_is_empty_Range_(self)
471        }
472    }
473
474    // RangeFrom<>
475
476    impl<Idx> super::IsEmpty for std_ops::RangeFrom<Idx> {
477        #[inline]
478        fn is_empty(&self) -> bool {
479            false
480        }
481    }
482
483    // RangeFull<>
484
485    impl super::IsEmpty for std_ops::RangeFull {
486        #[inline]
487        fn is_empty(&self) -> bool {
488            false
489        }
490    }
491
492    // RangeInclusive<>
493
494    impl<Idx : std_cmp::PartialOrd> super::IsEmpty for std_ops::RangeInclusive<Idx> {
495        #[inline]
496        fn is_empty(&self) -> bool {
497            isolate_::get_is_empty_RangeInclusive_(self)
498        }
499    }
500
501    // RangeTo<>
502
503    impl<Idx> super::IsEmpty for std_ops::RangeTo<Idx> {
504        #[inline]
505        fn is_empty(&self) -> bool {
506            false
507        }
508    }
509}
510
511
512#[cfg(all(not(feature = "nostd"), feature = "implement-IsEmpty-for-standard_time_types"))]
513mod impl_for_std_time_types {
514    #![allow(non_snake_case)]
515
516    use std::time as std_time;
517
518
519    // Duration
520
521    impl super::IsEmpty for std_time::Duration {
522        #[inline]
523        fn is_empty(&self) -> bool {
524            self.is_zero()
525        }
526    }
527
528    impl super::IsEmpty for &std_time::Duration {
529        #[inline]
530        fn is_empty(&self) -> bool {
531            self.is_zero()
532        }
533    }
534}
535
536
537#[cfg(test)]
538mod tests {
539    #![allow(non_snake_case)]
540
541    use super::IsEmpty;
542
543    use std::rc::Rc;
544
545
546    #[allow(unused)]
547    fn as_IsEmpty<T : IsEmpty>(t : &T) -> &impl IsEmpty {
548        t
549    }
550
551
552    mod TEST_CUSTOM_TYPE {
553        #![allow(non_snake_case)]
554
555        use super::*;
556
557
558        #[derive(Debug)]
559        struct CustomType {
560            num_elements : usize,
561        }
562
563        impl IsEmpty for CustomType {
564            fn is_empty(&self) -> bool {
565                0 == self.num_elements
566            }
567        }
568
569
570        #[test]
571        fn TEST_WHEN_ZERO_ELEMENTS() {
572            let ct = CustomType { num_elements : 0 };
573
574            assert!(ct.is_empty());
575
576            let ct = &ct;
577
578            assert!(ct.is_empty());
579        }
580
581        #[test]
582        fn TEST_WHEN_HAVE_ELEMENTS() {
583            let ct = CustomType { num_elements : 1 };
584
585            assert!(!ct.is_empty());
586
587            let ct = &ct;
588
589            assert!(!ct.is_empty());
590        }
591
592        #[test]
593        fn TEST_WHEN_ZERO_ELEMENTS_IN_Box() {
594            {
595                let ct = Box::new(CustomType { num_elements : 0 });
596
597                assert!(ct.is_empty());
598
599                let ct = &ct;
600
601                assert!(ct.is_empty());
602            }
603
604            {
605                let ct = &Box::new(CustomType { num_elements : 0 });
606
607                assert!(ct.is_empty());
608
609                let ct = &ct;
610
611                assert!(ct.is_empty());
612            }
613
614            {
615                let ct = Box::new(&CustomType { num_elements : 0 });
616
617                assert!(ct.is_empty());
618
619                let ct = &ct;
620
621                assert!(ct.is_empty());
622            }
623
624            {
625                let ct = &Box::new(&CustomType { num_elements : 0 });
626
627                assert!(ct.is_empty());
628
629                let ct = &ct;
630
631                assert!(ct.is_empty());
632            }
633        }
634
635        #[test]
636        fn TEST_WHEN_ZERO_ELEMENTS_IN_Rc() {
637            {
638                let ct = Rc::new(CustomType { num_elements : 0 });
639
640                assert!(ct.is_empty());
641
642                let ct = &ct;
643
644                assert!(ct.is_empty());
645            }
646
647            {
648                let ct = &Rc::new(CustomType { num_elements : 0 });
649
650                assert!(ct.is_empty());
651
652                let ct = &ct;
653
654                assert!(ct.is_empty());
655            }
656
657            {
658                let ct = Rc::new(&CustomType { num_elements : 0 });
659
660                assert!(ct.is_empty());
661
662                let ct = &ct;
663
664                assert!(ct.is_empty());
665            }
666
667            {
668                let ct = &Rc::new(&CustomType { num_elements : 0 });
669
670                assert!(ct.is_empty());
671
672                let ct = &ct;
673
674                assert!(ct.is_empty());
675            }
676        }
677    }
678
679
680    #[cfg(feature = "implement-IsEmpty-for-built_ins")]
681    mod TEST_BUILTIN_TYPES {
682        #![allow(non_snake_case)]
683
684        use super::*;
685
686
687        mod TEST_str {
688            #![allow(non_snake_case)]
689
690            use super::*;
691
692
693            #[test]
694            fn TEST_EMPTY() {
695                let s = "";
696
697                assert!(s.is_empty());
698
699                let ie = as_IsEmpty(&s);
700
701                assert!(ie.is_empty());
702            }
703
704            #[test]
705            fn TEST_NONEMPTY() {
706                let s = "abc";
707
708                assert!(!s.is_empty());
709
710                let ie = as_IsEmpty(&s);
711
712                assert!(!ie.is_empty());
713            }
714        }
715
716
717        mod TEST_Array {
718            #![allow(non_snake_case)]
719
720            use super::*;
721
722
723            #[test]
724            fn TEST_EMPTY() {
725                let ar : [i64; 0] = [];
726
727                assert!(ar.is_empty());
728
729                let ie = as_IsEmpty(&ar);
730
731                assert!(ie.is_empty());
732            }
733
734            #[test]
735            fn TEST_NONEMPTY() {
736                let ar : [i64; 1] = [ 0 ];
737
738                assert!(!ar.is_empty());
739
740                let ie = as_IsEmpty(&ar);
741
742                assert!(!ie.is_empty());
743            }
744        }
745
746
747        mod TEST_Slice {
748            #![allow(non_snake_case)]
749
750            use super::*;
751
752
753            #[test]
754            fn TEST_EMPTY() {
755                let ar : &[i64; 0] = &[];
756
757                assert!(ar.is_empty());
758
759                let ie = as_IsEmpty(&ar);
760
761                assert!(ie.is_empty());
762            }
763
764            #[test]
765            fn TEST_NONEMPTY() {
766                let ar = &[0];
767
768                assert!(!ar.is_empty());
769
770                let ie = as_IsEmpty(&ar);
771
772                assert!(!ie.is_empty());
773            }
774        }
775    }
776
777
778    #[cfg(feature = "implement-IsEmpty-for-standard_collection_types")]
779    mod TEST_STANDARD_TYPES {
780        #![allow(non_snake_case)]
781
782        use super::*;
783
784        use std::collections::{
785            BTreeMap,
786            BTreeSet,
787            BinaryHeap,
788            HashMap,
789            HashSet,
790            LinkedList,
791            VecDeque,
792        };
793
794
795        mod TEST_BTreeMapTU {
796            #![allow(non_snake_case)]
797
798            use super::*;
799
800
801            #[test]
802            fn TEST_EMPTY() {
803                let v : BTreeMap<i32, i32> = Default::default();
804
805                assert!(v.is_empty());
806
807                let ie = as_IsEmpty(&v);
808
809                assert!(ie.is_empty());
810            }
811
812            #[test]
813            fn TEST_NONEMPTY() {
814                let v = BTreeMap::from_iter(vec![ (0, 0) ]);
815
816                assert!(!v.is_empty());
817
818                let ie = as_IsEmpty(&v);
819
820                assert!(!ie.is_empty());
821            }
822        }
823
824
825        mod TEST_BTreeSetT {
826            #![allow(non_snake_case)]
827
828            use super::*;
829
830
831            #[test]
832            fn TEST_EMPTY() {
833                let v : BTreeSet<i32> = Default::default();
834
835                assert!(v.is_empty());
836
837                let ie = as_IsEmpty(&v);
838
839                assert!(ie.is_empty());
840            }
841
842            #[test]
843            fn TEST_NONEMPTY() {
844                let v = BTreeSet::from_iter(vec![ 0 ]);
845
846                assert!(!v.is_empty());
847
848                let ie = as_IsEmpty(&v);
849
850                assert!(!ie.is_empty());
851            }
852        }
853
854
855        mod TEST_BinaryHeapT {
856            #![allow(non_snake_case)]
857
858            use super::*;
859
860
861            #[test]
862            fn TEST_EMPTY() {
863                let v : BinaryHeap<i32> = Default::default();
864
865                assert!(v.is_empty());
866
867                let ie = as_IsEmpty(&v);
868
869                assert!(ie.is_empty());
870            }
871
872            #[test]
873            fn TEST_NONEMPTY() {
874                let v = BinaryHeap::from_iter(vec![ 0 ]);
875
876                assert!(!v.is_empty());
877
878                let ie = as_IsEmpty(&v);
879
880                assert!(!ie.is_empty());
881            }
882        }
883
884
885        mod TEST_HashMapTU {
886            #![allow(non_snake_case)]
887
888            use super::*;
889
890
891            #[test]
892            fn TEST_EMPTY() {
893                let v : HashMap<i32, i32> = Default::default();
894
895                assert!(v.is_empty());
896
897                let ie = as_IsEmpty(&v);
898
899                assert!(ie.is_empty());
900            }
901
902            #[test]
903            fn TEST_NONEMPTY() {
904                let v = HashMap::from_iter(vec![ (0, 0) ]);
905
906                assert!(!v.is_empty());
907
908                let ie = as_IsEmpty(&v);
909
910                assert!(!ie.is_empty());
911            }
912        }
913
914
915        mod TEST_HashSetT {
916            #![allow(non_snake_case)]
917
918            use super::*;
919
920
921            #[test]
922            fn TEST_EMPTY() {
923                let v : HashSet<i32> = Default::default();
924
925                assert!(v.is_empty());
926
927                let ie = as_IsEmpty(&v);
928
929                assert!(ie.is_empty());
930            }
931
932            #[test]
933            fn TEST_NONEMPTY() {
934                let v = HashSet::from_iter(vec![ 0 ]);
935
936                assert!(!v.is_empty());
937
938                let ie = as_IsEmpty(&v);
939
940                assert!(!ie.is_empty());
941            }
942        }
943
944
945        mod TEST_LinkedListT {
946            #![allow(non_snake_case)]
947
948            use super::*;
949
950
951            #[test]
952            fn TEST_EMPTY() {
953                let v : LinkedList<i32> = Default::default();
954
955                assert!(v.is_empty());
956
957                let ie = as_IsEmpty(&v);
958
959                assert!(ie.is_empty());
960            }
961
962            #[test]
963            fn TEST_NONEMPTY() {
964                let v = LinkedList::from_iter(vec![ 0 ]);
965
966                assert!(!v.is_empty());
967
968                let ie = as_IsEmpty(&v);
969
970                assert!(!ie.is_empty());
971            }
972        }
973
974
975        mod TEST_String {
976            #![allow(non_snake_case)]
977
978            use super::*;
979
980
981            #[test]
982            fn TEST_EMPTY() {
983                let s : String = "".into();
984
985                assert!(s.is_empty());
986
987                let ie = as_IsEmpty(&s);
988
989                assert!(ie.is_empty());
990            }
991
992            #[test]
993            fn TEST_NONEMPTY() {
994                let s : String = "abc".into();
995
996                assert!(!s.is_empty());
997
998                let ie = as_IsEmpty(&s);
999
1000                assert!(!ie.is_empty());
1001            }
1002        }
1003
1004
1005        mod TEST_String_IN_Box {
1006            #![allow(non_snake_case)]
1007
1008            use super::*;
1009
1010
1011            #[test]
1012            fn TEST_EMPTY() {
1013                let s : Box<String> = Box::new("".into());
1014
1015                assert!(s.is_empty());
1016
1017                let ie = as_IsEmpty(&s);
1018
1019                assert!(ie.is_empty());
1020            }
1021
1022            #[test]
1023            fn TEST_NONEMPTY() {
1024                let s : Box<String> = Box::new("abc".into());
1025
1026                assert!(!s.is_empty());
1027
1028                let ie = as_IsEmpty(&s);
1029
1030                assert!(!ie.is_empty());
1031            }
1032        }
1033
1034
1035        mod TEST_VecT {
1036            #![allow(non_snake_case)]
1037
1038            use super::*;
1039
1040
1041            #[test]
1042            fn TEST_EMPTY() {
1043                let v : Vec<i32> = Default::default();
1044
1045                assert!(v.is_empty());
1046
1047                let ie = as_IsEmpty(&v);
1048
1049                assert!(ie.is_empty());
1050            }
1051
1052            #[test]
1053            fn TEST_NONEMPTY() {
1054                let v : Vec<i32> = vec![ 0 ];
1055
1056                assert!(!v.is_empty());
1057
1058                let ie = as_IsEmpty(&v);
1059
1060                assert!(!ie.is_empty());
1061            }
1062        }
1063
1064
1065        mod TEST_VecDequeT {
1066            #![allow(non_snake_case)]
1067
1068            use super::*;
1069
1070
1071            #[test]
1072            fn TEST_EMPTY() {
1073                let v : VecDeque<i32> = Default::default();
1074
1075                assert!(v.is_empty());
1076
1077                let ie = as_IsEmpty(&v);
1078
1079                assert!(ie.is_empty());
1080            }
1081
1082            #[test]
1083            fn TEST_NONEMPTY() {
1084                let v = VecDeque::from_iter(vec![ 0 ]);
1085
1086                assert!(!v.is_empty());
1087
1088                let ie = as_IsEmpty(&v);
1089
1090                assert!(!ie.is_empty());
1091            }
1092        }
1093    }
1094
1095
1096    #[cfg(feature = "implement-IsEmpty-for-standard_ffi_types")]
1097    mod TEST_FFI_TYPES {
1098        #![allow(non_snake_case)]
1099
1100        use super::*;
1101
1102        use std::ffi::{
1103            CStr,
1104            CString,
1105        };
1106
1107
1108        mod TEST_CStr {
1109            #![allow(non_snake_case)]
1110
1111            use super::*;
1112
1113
1114            #[test]
1115            fn TEST_EMPTY() {
1116                let s : &CStr = &CString::new("").unwrap();
1117
1118                assert!(s.is_empty());
1119
1120                let ie = as_IsEmpty(&s);
1121
1122                assert!(ie.is_empty());
1123            }
1124
1125            #[test]
1126            fn TEST_NONEMPTY() {
1127                let s : &CStr = &CString::new("abc").unwrap();
1128
1129                assert!(!s.is_empty());
1130
1131                let ie = as_IsEmpty(&s);
1132
1133                assert!(!ie.is_empty());
1134            }
1135        }
1136
1137
1138        mod TEST_CString {
1139            #![allow(non_snake_case)]
1140
1141            use super::*;
1142
1143
1144            #[test]
1145            fn TEST_EMPTY() {
1146                let s : CString = CString::new("").unwrap();
1147
1148                assert!(s.is_empty());
1149
1150                let ie = as_IsEmpty(&s);
1151
1152                assert!(ie.is_empty());
1153            }
1154
1155            #[test]
1156            fn TEST_NONEMPTY() {
1157                let s : CString = CString::new("abc").unwrap();
1158
1159                assert!(!s.is_empty());
1160
1161                let ie = as_IsEmpty(&s);
1162
1163                assert!(!ie.is_empty());
1164            }
1165        }
1166    }
1167
1168
1169    #[cfg(feature = "implement-IsEmpty-for-standard_path_types")]
1170    mod TEST_PATH_TYPES {
1171        #![allow(non_snake_case)]
1172
1173        use super::*;
1174
1175        use std::path::{
1176            Path,
1177            PathBuf,
1178        };
1179
1180
1181        mod TEST_Path {
1182            #![allow(non_snake_case)]
1183
1184            use super::*;
1185
1186
1187            #[test]
1188            fn TEST_EMPTY() {
1189                let p = Path::new("");
1190
1191                assert!(p.is_empty());
1192
1193                let ie = as_IsEmpty(&p);
1194
1195                assert!(ie.is_empty());
1196            }
1197
1198            #[test]
1199            fn TEST_NOTEMPTY() {
1200                let p = Path::new("./foo/bar.txt");
1201
1202                assert!(!p.is_empty());
1203
1204                let ie = as_IsEmpty(&p);
1205
1206                assert!(!ie.is_empty());
1207            }
1208        }
1209
1210
1211        mod TEST_PathBuf {
1212            #![allow(non_snake_case)]
1213
1214            use super::*;
1215
1216
1217            #[test]
1218            fn TEST_EMPTY() {
1219                let p = PathBuf::new();
1220
1221                assert!(p.is_empty());
1222
1223                let ie = as_IsEmpty(&p);
1224
1225                assert!(ie.is_empty());
1226            }
1227
1228            #[test]
1229            fn TEST_NOTEMPTY() {
1230                let mut p = PathBuf::new();
1231
1232                p.push("./foo/bar.txt");
1233
1234                assert!(!p.is_empty());
1235
1236                let ie = as_IsEmpty(&p);
1237
1238                assert!(!ie.is_empty());
1239            }
1240        }
1241    }
1242
1243
1244    #[cfg(feature = "implement-IsEmpty-for-standard_process_types")]
1245    mod TEST_PROCESS_TYPES {
1246        #![allow(non_snake_case)]
1247
1248    }
1249
1250
1251    #[cfg(feature = "implement-IsEmpty-for-standard_range_types")]
1252    mod TEST_RANGE_TYPES {
1253        #![allow(non_snake_case)]
1254
1255        use super::*;
1256
1257
1258        mod TEST_Range {
1259            #![allow(non_snake_case)]
1260
1261            use super::*;
1262
1263
1264            #[test]
1265            fn TEST_EMPTY() {
1266                let r = 0..0;
1267
1268                assert!(r.is_empty());
1269
1270                let ie = as_IsEmpty(&r);
1271
1272                assert!(ie.is_empty());
1273            }
1274
1275            #[test]
1276            fn TEST_NONEMPTY() {
1277                let r = 0..1;
1278
1279                assert!(!r.is_empty());
1280
1281                let ie = as_IsEmpty(&r);
1282
1283                assert!(!ie.is_empty());
1284            }
1285        }
1286
1287
1288        mod TEST_RangeFrom {
1289            #![allow(non_snake_case)]
1290
1291            use super::*;
1292
1293
1294            #[test]
1295            fn TEST_NONEMPTY() {
1296                let r = 0..;
1297
1298                assert!(!r.is_empty());
1299
1300                let ie = as_IsEmpty(&r);
1301
1302                assert!(!ie.is_empty());
1303            }
1304        }
1305
1306
1307        mod TEST_RangeFull {
1308            #![allow(non_snake_case)]
1309
1310            use super::*;
1311
1312
1313            #[test]
1314            fn TEST_NONEMPTY() {
1315                let r = ..;
1316
1317                assert!(!r.is_empty());
1318
1319                let ie = as_IsEmpty(&r);
1320
1321                assert!(!ie.is_empty());
1322            }
1323        }
1324
1325
1326        mod TEST_RangeInclusive {
1327            #![allow(non_snake_case)]
1328
1329            use super::*;
1330
1331
1332            #[test]
1333            fn TEST_NONEMPTY() {
1334                let r = 0..=1;
1335
1336                assert!(!r.is_empty());
1337
1338                let ie = as_IsEmpty(&r);
1339
1340                assert!(!ie.is_empty());
1341            }
1342        }
1343
1344
1345        mod TEST_RangeTo {
1346            #![allow(non_snake_case)]
1347
1348            use super::*;
1349
1350
1351            #[test]
1352            fn TEST_NONEMPTY() {
1353                let r = ..1;
1354
1355                assert!(!r.is_empty());
1356
1357                let ie = as_IsEmpty(&r);
1358
1359                assert!(!ie.is_empty());
1360            }
1361        }
1362    }
1363
1364
1365    #[cfg(feature = "implement-IsEmpty-for-standard_time_types")]
1366    mod TEST_TIME_TYPES {
1367        #![allow(non_snake_case)]
1368
1369        use super::*;
1370
1371        use std::time::{
1372            Duration,
1373        };
1374
1375
1376        mod TEST_Duration {
1377            #![allow(non_snake_case)]
1378
1379            use super::*;
1380
1381
1382            #[test]
1383            fn TEST_EMPTY() {
1384                let d = Duration::from_micros(0);
1385
1386                assert!(d.is_empty());
1387
1388                let ie = as_IsEmpty(&d);
1389
1390                assert!(ie.is_empty());
1391            }
1392
1393            #[test]
1394            fn TEST_NONEMPTY() {
1395                let d = Duration::from_micros(1);
1396
1397                assert!(!d.is_empty());
1398
1399                let ie = as_IsEmpty(&d);
1400
1401                assert!(!ie.is_empty());
1402            }
1403        }
1404    }
1405}
1406
1407
1408// ///////////////////////////// end of file //////////////////////////// //
1409