Enum flux_middle::MaybeExternId

source ·
pub enum MaybeExternId<Id = LocalDefId> {
    Local(Id),
    Extern(Id, DefId),
}
Expand description

This enum serves as a type-level reminder that a local definition may be a wrapper for an extern spec. This abstraction is not infallible, so one should be careful and decide in each situation whether to use the local id or the resolved id.

The construction of MaybeExternId is not encapsulated, but it is recommended to use GlobalEnv::maybe_extern_id to create one.

The enum is generic on the local Id as we use it with various kinds of local ids, e.g., LocalDefId, [OwnerId], …

Variants§

§

Local(Id)

An id for a local spec.

§

Extern(Id, DefId)

A “dummy” local definition wrapping an external spec. The Id is the local id of the definition corresponding to the extern spec. The DefId is the resolved id for the external definition.

Implementations§

source§

impl<Id> MaybeExternId<Id>

source

pub fn map<R>(self, f: impl FnOnce(Id) -> R) -> MaybeExternId<R>

source

pub fn local_id(self) -> Id

source

pub fn expect_local(self) -> Id

source

pub fn is_local(self) -> bool

Returns true if the maybe extern id is Local.

source

pub fn is_extern(&self) -> bool

Returns true if the maybe extern id is Extern.

source

pub fn as_local(self) -> Option<Id>

source

pub fn as_extern(self) -> Option<DefId>

source§

impl<Id: Into<DefId>> MaybeExternId<Id>

source

pub fn resolved_id(self) -> DefId

Returns the DefId this id truly corresponds to, i.e, returns the DefId of the extern definition if Extern or converts the local id into a DefId if Local.

Trait Implementations§

source§

impl<Id: Clone> Clone for MaybeExternId<Id>

source§

fn clone(&self) -> MaybeExternId<Id>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Id: Debug> Debug for MaybeExternId<Id>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl IntoQueryParam<DefId> for MaybeExternId

source§

impl<Id: Copy> Copy for MaybeExternId<Id>

Auto Trait Implementations§

§

impl<Id> Freeze for MaybeExternId<Id>
where Id: Freeze,

§

impl<Id> RefUnwindSafe for MaybeExternId<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for MaybeExternId<Id>
where Id: Send,

§

impl<Id> Sync for MaybeExternId<Id>
where Id: Sync,

§

impl<Id> Unpin for MaybeExternId<Id>
where Id: Unpin,

§

impl<Id> UnwindSafe for MaybeExternId<Id>
where Id: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<P> IntoQueryParam<P> for P

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.