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