I wanted to create a method that only works where the self parameter was an Rc. I saw that I could use Box, so I thought I might try to mimic how that works:
use std::rc::Rc; use std::sync::Arc; struct Bar; impl Bar { fn consuming(self) {} fn reference(&self) {} fn mutable_reference(&mut self) {} fn boxed(self: Box<Bar>) {} fn ref_count(self: Rc<Bar>) {} fn atomic_ref_count(self: Arc<Bar>) {} } fn main() {} Yields these errors:
error[E0308]: mismatched method receiver --> a.rs:11:18 | 11 | fn ref_count(self: Rc<Bar>) {} | ^^^^ expected struct `Bar`, found struct `std::rc::Rc` | = note: expected type `Bar` = note: found type `std::rc::Rc<Bar>` error[E0308]: mismatched method receiver --> a.rs:12:25 | 12 | fn atomic_ref_count(self: Arc<Bar>) {} | ^^^^ expected struct `Bar`, found struct `std::sync::Arc` | = note: expected type `Bar` = note: found type `std::sync::Arc<Bar>` This is with Rust 1.15.1.