2 #![allow(unused_variables)]
3 // Check that a trait is still object-safe (and usable) if it has
4 // generic methods so long as they require `Self : Sized`.
8 fn tick(&mut self) -> u32;
9 fn with<F:FnOnce(u32)>(&self, f: F) where Self : Sized;
16 impl Counter for CCounter {
17 fn tick(&mut self) -> u32 { self.c += 1; self.c }
18 fn with<F:FnOnce(u32)>(&self, f: F) { f(self.c); }
21 fn tick1<C:Counter>(c: &mut C) {
26 fn tick2(c: &mut dyn Counter) {
30 fn tick3<C:?Sized+Counter>(c: &mut C) {
36 let mut c = CCounter { c: 0 };
38 assert_eq!(c.tick(), 3);