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