#![allow(unused)] use std::collections::{HashMap, HashSet}; use std::cmp::Eq; use std::hash::{Hash, BuildHasher}; pub trait Foo: Sized { fn make() -> (Self, Self); } impl Foo for HashMap { fn make() -> (Self, Self) { // OK, don't suggest to modify these let _: HashMap = HashMap::new(); let _: HashSet = HashSet::new(); (HashMap::new(), HashMap::with_capacity(10)) } } impl Foo for (HashMap,) { fn make() -> (Self, Self) { ((HashMap::new(),), (HashMap::with_capacity(10),)) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::new(), HashMap::with_capacity(10)) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::new(), HashSet::with_capacity(10)) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::new(), HashSet::with_capacity(10)) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } } pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { } macro_rules! gen { (impl) => { impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::new(), HashMap::with_capacity(10)) } } }; (fn $name:ident) => { pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { } } } gen!(impl); gen!(fn bar); fn main() {}