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) -> Self
pub fn new(handle: H) -> Self
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: Self) -> ManuallyDrop<H>
pub unsafe fn into_inner(this: Self) -> 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: Edge> Borrowed<'a, E>
impl<'a, E: Edge> Borrowed<'a, E>
Sourcepub fn edge_with_tag(self, tag: E::Tag) -> Self
pub fn edge_with_tag(self, tag: E::Tag) -> Self
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.