File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
library/alloc/src/collections/btree/set Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use super::super::testing::rng::DeterministicRng;
33use super :: * ;
44use crate :: vec:: Vec ;
55use std:: cmp:: Ordering ;
6+ use std:: hash:: { Hash , Hasher } ;
67use std:: iter:: FromIterator ;
78use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
89
@@ -607,6 +608,37 @@ fn assert_send() {
607608 }
608609}
609610
611+ #[ allow( dead_code) ]
612+ // Check that the member-like functions conditionally provided by #[derive()]
613+ // are not overriden by genuine member functions with a different signature.
614+ fn assert_derives ( ) {
615+ fn hash < T : Hash , H : Hasher > ( v : BTreeSet < T > , state : & mut H ) {
616+ v. hash ( state) ;
617+ // Tested much more thoroughly outside the crate in btree_set_hash.rs
618+ }
619+ fn eq < T : PartialEq > ( v : BTreeSet < T > ) {
620+ let _ = v. eq ( & v) ;
621+ }
622+ fn ne < T : PartialEq > ( v : BTreeSet < T > ) {
623+ let _ = v. ne ( & v) ;
624+ }
625+ fn cmp < T : Ord > ( v : BTreeSet < T > ) {
626+ let _ = v. cmp ( & v) ;
627+ }
628+ fn min < T : Ord > ( v : BTreeSet < T > , w : BTreeSet < T > ) {
629+ let _ = v. min ( w) ;
630+ }
631+ fn max < T : Ord > ( v : BTreeSet < T > , w : BTreeSet < T > ) {
632+ let _ = v. max ( w) ;
633+ }
634+ fn clamp < T : Ord > ( v : BTreeSet < T > , w : BTreeSet < T > , x : BTreeSet < T > ) {
635+ let _ = v. clamp ( w, x) ;
636+ }
637+ fn partial_cmp < T : PartialOrd > ( v : & BTreeSet < T > ) {
638+ let _ = v. partial_cmp ( & v) ;
639+ }
640+ }
641+
610642#[ test]
611643fn test_ord_absence ( ) {
612644 fn set < K > ( mut set : BTreeSet < K > ) {
You can’t perform that action at this time.
0 commit comments