Trait partial_ref::PartialRef [−][src]
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<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a self,
_part: FieldPartSpec
) -> &'a FieldType
where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckConst<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a, { ... } fn part_mut<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> &'a mut FieldType
where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
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<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a FieldType, Self::Remainder)
where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckConst<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a, { ... } fn split_part_mut<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a mut FieldType, Self::Remainder)
where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckMut<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a, { ... } }
Expand description
Required methods
Create a partial reference from a raw pointer.
Safety
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.
Provided methods
fn borrow<BorrowedRef, SubsetIndex>(&'a mut self) -> BorrowedRef where
BorrowedRef: PartialRef<'a, Target = Self::Target>,
Self: HasSubset<'a, BorrowedRef, SubsetIndex>,
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.
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<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> &'a mut FieldType where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckMut<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a,
fn part_mut<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> &'a mut FieldType where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
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>,
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<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a FieldType, Self::Remainder) where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckConst<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a,
fn split_part<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a FieldType, Self::Remainder) where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
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<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a mut FieldType, Self::Remainder) where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
Self: PluckMut<'a, FieldPart, PartIndex>,
Self::Target: HasPart<FieldPart> + 'a,
fn split_part_mut<FieldPartSpec, FieldPart, PartIndex, FieldType>(
&'a mut self,
_part: FieldPartSpec
) -> (&'a mut FieldType, Self::Remainder) where
FieldType: ?Sized,
FieldPart: Part<PartType = Field<FieldType>>,
FieldPartSpec: PartSpec<FieldPart>,
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
.
Implementors
impl<'a, SomePart: Part, Reference: PartialRef<'a>> PartialRef<'a> for Const<SomePart, Reference> where
Reference::Target: HasPart<SomePart>,
impl<'a, SomePart: Part, Reference: PartialRef<'a>> PartialRef<'a> for Mut<SomePart, Reference> where
Reference::Target: HasPart<SomePart>,