Skip to main content

IntoQueryKey

Trait IntoQueryKey 

Source
pub trait IntoQueryKey<K> {
    // Required method
    fn into_query_key(self) -> K;
}
Expand description

Argument-conversion trait used by some queries and other TyCtxt methods.

A function that accepts an impl IntoQueryKey<DefId> argument can be thought of as taking a DefId, except that callers can also pass a LocalDefId or values of other narrower ID types, as long as they have a trivial conversion to DefId.

Using a dedicated trait instead of Into makes the purpose of the conversion more explicit, and makes occurrences easier to search for.

Required Methods§

Source

fn into_query_key(self) -> K

Argument conversion from Self to K. This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.

Implementations on Foreign Types§

Source§

impl IntoQueryKey<DefId> for OwnerId

Source§

impl IntoQueryKey<DefId> for LocalDefId

Source§

impl IntoQueryKey<DefId> for LocalModDefId

Source§

impl IntoQueryKey<DefId> for ModDefId

Source§

impl IntoQueryKey<LocalDefId> for OwnerId

Source§

impl IntoQueryKey<LocalDefId> for LocalModDefId

Implementors§

Source§

impl<K> IntoQueryKey<K> for K

Any type can be converted to itself.

This is useful in generic or macro-generated code where we don’t know whether conversion is actually needed, so that we can do a conversion unconditionally.