pub struct My<T: ?Sized> { /* private fields */ }Expand description
A dynamic exclusively-owning smart pointer to a value
Implementations§
Source§impl<T: ?Sized> My<T>
impl<T: ?Sized> My<T>
Sourcepub fn borrow(&self) -> Dyb<T>
pub fn borrow(&self) -> Dyb<T>
Dynamically borrow the value
This borrow may live for any lifetime less than that of the bounds on the value itself - notably, this implies that (as far as the borrow-checker is concerned) it may outlive the owner itself!
This actually shifts the responsibility for ensuring the value lives long enough back onto the owner (just like the static borrow checker) with the caveat that dropping the value early will fail at runtime.
Dybs satisfies this requirement by leaking the value and panicking
in this case. The leaking ensures soundness as in the worst case the
value will just live forever, while panicking ensures the error is
reported at the appropriate time rather than unfairly blaming a Dyb
for holding a borrow for “too long” or entirely ignoring the problem.