On Tue, May 13, 2014 at 2:19 PM, Alex Crichton <a...@crichton.co> wrote: > The ~int type has since moved to Box<int>, which will one day be a > library type with Deref implemented on it (currently it is implemented > by the compiler).
Thanks for the note. I'm using a slightly older version that doesn't have Box<T>, but it sounds like ~ is also implemented with the compiler. I was actually looking into this because I was interested in intercepting the deref (as well as allocate/free) for some distributed shared-memory experiments. Some of the safety checks rust performs simplifies the coherency requirements needed of the storage layer (e.g. expensive locking). -Noah > > On Mon, May 12, 2014 at 11:50 AM, Noah Watkins <jayh...@cs.ucsc.edu> wrote: >> I am trying to capture the reference to type `~int` with the following >> code. I can change it to apply to bare `int` and it works fine. >> >> #[lang="deref"] >> pub trait Deref<Result> { >> fn deref<'a>(&'a self) -> &'a Result; >> } >> >> impl Deref<~int> for ~int { >> fn deref<'a>(&'a self) -> &'a ~int { >> println!("deref caught"); >> self >> } >> } >> >> fn main() { >> let x: ~int = 3; >> *x >> } >> >> Thanks, >> Noah >> _______________________________________________ >> Rust-dev mailing list >> Rust-dev@mozilla.org >> https://mail.mozilla.org/listinfo/rust-dev _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev