pub struct Borrowed<'a, H>(/* private fields */);Expand description
Borrowed version of some handle
A handle is typically just a pointer, but we cannot copy it as we need to update the reference counters accordingly. However, if we want to have multiple instances of the same handle without changing the reference counters, we can use shared references. This works as long as one does not attempt to change the handle’s tag. In this case, we need ownership of the handle with the different tag, but need to restrict its lifetime to the one of the original handle. Furthermore, we must not drop the new handle. This is exactly, what this data structure provides.
Borrowed<'a, H> always has the same representation as H.
Implementations§
Source§impl<'a, H> Borrowed<'a, H>
impl<'a, H> Borrowed<'a, H>
Sourcepub fn new(handle: H) -> Borrowed<'a, H>
pub fn new(handle: H) -> Borrowed<'a, H>
Create a new borrowed handle
While the type of handle suggests that the handle is owned, it should
be just the owned representation of a borrowed handle, e.g. no reference
counters should be increased when creating handle.
Sourcepub unsafe fn into_inner(this: Borrowed<'a, H>) -> ManuallyDrop<H>
pub unsafe fn into_inner(this: Borrowed<'a, H>) -> ManuallyDrop<H>
Convert a borrowed handle into the underlying ManuallyDrop handle
§Safety
The caller must ensure that the resources referenced by the handle remain valid during its usage. Furthermore the returned handle must not be dropped.
Source§impl<'a, E> Borrowed<'a, E>where
E: Edge,
impl<'a, E> Borrowed<'a, E>where
E: Edge,
Sourcepub fn edge_with_tag(self, tag: <E as Edge>::Tag) -> Borrowed<'a, E>
pub fn edge_with_tag(self, tag: <E as Edge>::Tag) -> Borrowed<'a, E>
Change the tag of a borrowed Edge
This is equivalent to Edge::with_tag(), but can be used in some
situations where Edge::with_tag() can’t due to lifetime
restrictions.
Trait Implementations§
Source§impl<'a, H> Ord for Borrowed<'a, H>where
H: Ord,
impl<'a, H> Ord for Borrowed<'a, H>where
H: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, H> PartialOrd for Borrowed<'a, H>where
H: PartialOrd,
impl<'a, H> PartialOrd for Borrowed<'a, H>where
H: PartialOrd,
impl<'a, H> Eq for Borrowed<'a, H>where
H: Eq,
impl<'a, H> StructuralPartialEq for Borrowed<'a, H>
Auto Trait Implementations§
impl<'a, H> Freeze for Borrowed<'a, H>where
H: Freeze,
impl<'a, H> RefUnwindSafe for Borrowed<'a, H>where
H: RefUnwindSafe,
impl<'a, H> Send for Borrowed<'a, H>
impl<'a, H> Sync for Borrowed<'a, H>where
H: Sync,
impl<'a, H> Unpin for Borrowed<'a, H>where
H: Unpin,
impl<'a, H> UnwindSafe for Borrowed<'a, H>where
H: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more