use std::ops::Deref; use std::sync::Arc; use inspection::Repr; /// A shared immutable handle to an abstract shape. #[derive(Clone)] pub struct ShapeHandle { handle: Arc>> } impl ShapeHandle { /// Creates a sharable shape handle from a shape. #[inline] pub fn new>(shape: S) -> ShapeHandle { ShapeHandle { handle: Arc::new(Box::new(shape) as Box>) } } } impl AsRef> for ShapeHandle { #[inline] fn as_ref(&self) -> &Repr { self.deref() } } impl Deref for ShapeHandle { type Target = Repr; #[inline] fn deref(&self) -> &Repr { &**self.handle } }