mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-03 05:27:36 +00:00
BTree: assert presence of derived functions
This commit is contained in:
parent
c8bc4b7a55
commit
cc35a11a39
@ -3,6 +3,7 @@ use super::super::testing::rng::DeterministicRng;
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::vec::Vec;
|
use crate::vec::Vec;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||||
|
|
||||||
@ -607,6 +608,37 @@ fn assert_send() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// Check that the member-like functions conditionally provided by #[derive()]
|
||||||
|
// are not overriden by genuine member functions with a different signature.
|
||||||
|
fn assert_derives() {
|
||||||
|
fn hash<T: Hash, H: Hasher>(v: BTreeSet<T>, state: &mut H) {
|
||||||
|
v.hash(state);
|
||||||
|
// Tested much more thoroughly outside the crate in btree_set_hash.rs
|
||||||
|
}
|
||||||
|
fn eq<T: PartialEq>(v: BTreeSet<T>) {
|
||||||
|
let _ = v.eq(&v);
|
||||||
|
}
|
||||||
|
fn ne<T: PartialEq>(v: BTreeSet<T>) {
|
||||||
|
let _ = v.ne(&v);
|
||||||
|
}
|
||||||
|
fn cmp<T: Ord>(v: BTreeSet<T>) {
|
||||||
|
let _ = v.cmp(&v);
|
||||||
|
}
|
||||||
|
fn min<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
|
||||||
|
let _ = v.min(w);
|
||||||
|
}
|
||||||
|
fn max<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>) {
|
||||||
|
let _ = v.max(w);
|
||||||
|
}
|
||||||
|
fn clamp<T: Ord>(v: BTreeSet<T>, w: BTreeSet<T>, x: BTreeSet<T>) {
|
||||||
|
let _ = v.clamp(w, x);
|
||||||
|
}
|
||||||
|
fn partial_cmp<T: PartialOrd>(v: &BTreeSet<T>) {
|
||||||
|
let _ = v.partial_cmp(&v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ord_absence() {
|
fn test_ord_absence() {
|
||||||
fn set<K>(mut set: BTreeSet<K>) {
|
fn set<K>(mut set: BTreeSet<K>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user