Enum hir_ty::mir::BorrowKind
source · pub enum BorrowKind {
Shared,
Shallow,
Mut {
kind: MutBorrowKind,
},
}
Variants§
Data must be immutable and is aliasable.
Shallow
The immediately borrowed place must be immutable, but projections from
it don’t need to be. For example, a shallow borrow of a.b
doesn’t
conflict with a mutable borrow of a.b.c
.
This is used when lowering matches: when matching on a place we want to ensure that place have the same value from the start of the match until an arm is selected. This prevents this code from compiling:
ⓘ
let mut x = &Some(0);
match *x {
None => (),
Some(_) if { x = &None; false } => (),
Some(_) => (),
}
This can’t be a shared borrow because mutably borrowing (*x as Some).0
should not prevent if let None = x { ... }
, for example, because the
mutating (*x as Some).0
can’t affect the discriminant of x
.
We can also report errors with this kind of borrow differently.
Mut
Data is mutable and not aliasable.
Fields
§
kind: MutBorrowKind
Trait Implementations§
source§impl Clone for BorrowKind
impl Clone for BorrowKind
source§fn clone(&self) -> BorrowKind
fn clone(&self) -> BorrowKind
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for BorrowKind
impl Debug for BorrowKind
source§impl Ord for BorrowKind
impl Ord for BorrowKind
source§fn cmp(&self, other: &BorrowKind) -> Ordering
fn cmp(&self, other: &BorrowKind) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for BorrowKind
impl PartialEq for BorrowKind
source§impl PartialOrd for BorrowKind
impl PartialOrd for BorrowKind
impl Copy for BorrowKind
impl Eq for BorrowKind
impl StructuralPartialEq for BorrowKind
Auto Trait Implementations§
impl Freeze for BorrowKind
impl RefUnwindSafe for BorrowKind
impl Send for BorrowKind
impl Sync for BorrowKind
impl Unpin for BorrowKind
impl UnwindSafe for BorrowKind
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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