Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::borrow::Borrow;
- pub trait IntoIterExt: IntoIterator {
- fn contains_any_of<U>(self, other: U) -> bool where Self::Item: PartialEq,
- U: IntoIterator,
- U::Item: Borrow<Self::Item>;
- }
- impl<T: IntoIterator> IntoIterExt for T {
- fn contains_any_of<U>(self, _other: U) -> bool where Self::Item: PartialEq,
- U: IntoIterator,
- U::Item: Borrow<Self::Item> {
- true
- }
- }
- #[test]
- fn contains_empty_coll_contains_empty_vec_yields_true() {
- // given an empty collection
- let coll = Vec::<i32>::new();
- // when `contains()` invoked with `Vec` empty set
- let result = coll.contains_any_of(Vec::<i32>::new());
- // then the result should be true
- assert_eq!(true, result);
- }
- #[test]
- fn contains_empty_coll_contains_empty_slice_yields_true() {
- // given an empty collection
- let coll = Vec::<i32>::new();
- // when `contains()` invoked with `slice` empty set
- let result = coll.contains_any_of(&[]);
- // then the result should be true
- assert_eq!(true, result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement