[][src]Trait partial_ref::PartialRef

pub trait PartialRef<'a>: HasTarget + Sized {
    unsafe fn from_raw(
        ptr: *mut <Self::Target as PartialRefTarget>::RawTarget
    ) -> Self;
fn get_raw(&self) -> *mut <Self::Target as PartialRefTarget>::RawTarget; fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef
    where
        BorrowedRef: PartialRef<'a, Target = Self::Target>,
        Self: HasSubset<'a, BorrowedRef, SubsetIndex>
, { ... }
fn part<FieldPart, PartIndex, FieldType>(
        &'a self,
        _part: FieldPart
    ) -> &'a FieldType
    where
        FieldType: ?Sized,
        FieldPart: Part<PartType = Field<FieldType>>,
        Self: PluckConst<'a, FieldPart, PartIndex>,
        Self::Target: HasPart<FieldPart> + 'a
, { ... }
fn part_mut<FieldPart, PartIndex, FieldType>(
        &'a mut self,
        _part: FieldPart
    ) -> &'a mut FieldType
    where
        FieldType: ?Sized,
        FieldPart: Part<PartType = Field<FieldType>>,
        Self: PluckMut<'a, FieldPart, PartIndex>,
        Self::Target: HasPart<FieldPart> + 'a
, { ... }
fn split_borrow<BorrowedRef, SubsetIndex>(
        &'a mut self
    ) -> (BorrowedRef, Self::Remainder)
    where
        BorrowedRef: PartialRef<'a, Target = Self::Target>,
        Self: HasSubset<'a, BorrowedRef, SubsetIndex>
, { ... }
fn split_part<FieldPart, PartIndex, FieldType>(
        &'a mut self,
        _part: FieldPart
    ) -> (&'a FieldType, Self::Remainder)
    where
        FieldType: ?Sized,
        FieldPart: Part<PartType = Field<FieldType>>,
        Self: PluckConst<'a, FieldPart, PartIndex>,
        Self::Target: HasPart<FieldPart> + 'a
, { ... }
fn split_part_mut<FieldPart, PartIndex, FieldType>(
        &'a mut self,
        _part: FieldPart
    ) -> (&'a mut FieldType, Self::Remainder)
    where
        FieldType: ?Sized,
        FieldPart: Part<PartType = Field<FieldType>>,
        Self: PluckMut<'a, FieldPart, PartIndex>,
        Self::Target: HasPart<FieldPart> + 'a
, { ... } }

A partial reference.

This is implemented by variants of Ref, Mut and Const. This is only implemented if the parts of any contained Mut or Const are valid for the referenced type.

Required methods

unsafe fn from_raw(
    ptr: *mut <Self::Target as PartialRefTarget>::RawTarget
) -> Self

Create a partial reference from a raw pointer.

This is unsafe for two reasons. It can be used to dereference a raw pointer, which is already unsafe on its own, and it can be used to construct invalid partial references, for example containing the same mutable part twice. Thus extra care is required when calling this.

fn get_raw(&self) -> *mut <Self::Target as PartialRefTarget>::RawTarget

Access to the underlying raw pointer.

Beware that this can be used even for an empty reference with no parts. Doing anything with the resulting pointer is very likely unsafe, even if the partial reference is still in scope.

Loading content...

Provided methods

fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 

Partially re-borrows a partial reference.

This returns a new partial reference to the same value. The returned reference can have a subset of the original reference's parts.

A typical use case is passing a reference to a function that requires fewer parts than the caller.

Usually the type parameters can be inferred.

fn part<FieldPart, PartIndex, FieldType>(
    &'a self,
    _part: FieldPart
) -> &'a FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 

Access a part of the referenced value.

This returns a plain reference to a single part.

The parameter is only present for type inference, its value is ignored. As all parts implement Default it is always possible to pass a default value, which is useful in generic code.

Usually the type parameters can be inferred.

fn part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> &'a mut FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 

Mutable access to a part of the referenced value.

This returns a plain mutable reference to a single part.

The parameter is only present for type inference, its value is ignored. As all parts implement Default it is always possible to pass a default value, which is useful in generic code.

Usually the type parameters can be inferred.

fn split_borrow<BorrowedRef, SubsetIndex>(
    &'a mut self
) -> (BorrowedRef, Self::Remainder) where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 

Partially re-borrows a partial reference, splitting off the remaining parts.

This is equivalent to borrow but also returns a second partial reference that contains all parts that can be used simultaneously with the re-borrowed reference.

This means that constant parts are contained in both references, while mutable parts that are re-borrowed are missing from the second partial reference. Mutable parts that are re-borrowed as constant parts are constant parts of both references.

Usually the type parameters can be inferred.

fn split_part<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 

Access a part of the referenced value, splitting off the remaining parts.

This is equivalent to part but also returns a partial reference as described in split_borrow.

fn split_part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a mut FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 

Mutable access to a part of the referenced value, splitting off the remaining parts.

This is equivalent to part_mut but also returns a partial reference as described in split_borrow.

Loading content...

Implementors

impl<'a, 'b: 'a, Target: PartialRefTarget + ?Sized> PartialRef<'a> for Ref<'b, Target>[src]

An empty reference to a valid target is a valid reference.

fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn part<FieldPart, PartIndex, FieldType>(
    &'a self,
    _part: FieldPart
) -> &'a FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> &'a mut FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_borrow<BorrowedRef, SubsetIndex>(
    &'a mut self
) -> (BorrowedRef, Self::Remainder) where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn split_part<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a mut FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

impl<'a, SomePart: Part, Reference: PartialRef<'a>> PartialRef<'a> for Const<SomePart, Reference> where
    Reference::Target: HasPart<SomePart>, 
[src]

Extending a valid reference by a constant part is still a valid reference when the reference target has such a part.

fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn part<FieldPart, PartIndex, FieldType>(
    &'a self,
    _part: FieldPart
) -> &'a FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> &'a mut FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_borrow<BorrowedRef, SubsetIndex>(
    &'a mut self
) -> (BorrowedRef, Self::Remainder) where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn split_part<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a mut FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

impl<'a, SomePart: Part, Reference: PartialRef<'a>> PartialRef<'a> for Mut<SomePart, Reference> where
    Reference::Target: HasPart<SomePart>, 
[src]

Extending a valid reference by a mutable part is still a valid reference when the reference target has such a part.

fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn part<FieldPart, PartIndex, FieldType>(
    &'a self,
    _part: FieldPart
) -> &'a FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> &'a mut FieldType where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_borrow<BorrowedRef, SubsetIndex>(
    &'a mut self
) -> (BorrowedRef, Self::Remainder) where
    BorrowedRef: PartialRef<'a, Target = Self::Target>,
    Self: HasSubset<'a, BorrowedRef, SubsetIndex>, 
[src]

fn split_part<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckConst<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

fn split_part_mut<FieldPart, PartIndex, FieldType>(
    &'a mut self,
    _part: FieldPart
) -> (&'a mut FieldType, Self::Remainder) where
    FieldType: ?Sized,
    FieldPart: Part<PartType = Field<FieldType>>,
    Self: PluckMut<'a, FieldPart, PartIndex>,
    Self::Target: HasPart<FieldPart> + 'a, 
[src]

Loading content...