Skip to content

Instantly share code, notes, and snippets.

@JoeyEremondi
Last active September 22, 2016 22:48
Show Gist options
  • Save JoeyEremondi/c818d465715f81d662be1cea88fa982e to your computer and use it in GitHub Desktop.
Save JoeyEremondi/c818d465715f81d662be1cea88fa982e to your computer and use it in GitHub Desktop.
use std::boxed::Box;
use std::rc::Rc;
use std::borrow::Borrow;
use std::mem;
struct BP_Borrow;
struct BP_RC;
trait BorrowPlus<Borrowed, TRef> : Borrow<Borrowed>
{
}
fn asRc<Borrowed, BorrowType>(val : BorrowType) -> Rc<Borrowed>
where BorrowType : BorrowPlus<Borrowed, BP_RC>
{
unsafe { mem::transmute::<BorrowType, Rc<Borrowed> > (val)}
}
fn main(){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment