Struct Borrowed

Source
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>

Source

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.

Source

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>

Source

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.

Trait Implementations§

Source§

impl<'a, H> Deref for Borrowed<'a, H>

Source§

type Target = H

The resulting type after dereferencing.
Source§

fn deref(&self) -> &H

Dereferences the value.
Source§

impl<'a, H: Ord> Ord for Borrowed<'a, H>

Source§

fn cmp(&self, other: &Borrowed<'a, H>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a, H: PartialEq> PartialEq for Borrowed<'a, H>

Source§

fn eq(&self, other: &Borrowed<'a, H>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, H: PartialOrd> PartialOrd for Borrowed<'a, H>

Source§

fn partial_cmp(&self, other: &Borrowed<'a, H>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, H: Eq> Eq for Borrowed<'a, H>

Source§

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>
where H: Send + Sync,

§

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>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.