Type Alias Visibility

Source
type Visibility = Visibility<LocalDefId>;

Aliased Type§

enum Visibility {
    Public,
    Restricted(LocalDefId),
}

Variants§

§

Public

Visible everywhere (including in other crates).

§

Restricted(LocalDefId)

Visible only in the given crate-local module.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 4 bytes

Size for each variant:

  • Public: 0 bytes
  • Restricted: 4 bytes

Implementations

Source§

impl<Id> Visibility<Id>

Source

pub fn is_public(self) -> bool

Source

pub fn map_id<OutId>(self, f: impl FnOnce(Id) -> OutId) -> Visibility<OutId>

Source§

impl<Id> Visibility<Id>
where Id: Into<DefId>,

Source

pub fn to_def_id(self) -> Visibility<DefId>

Source

pub fn is_accessible_from( self, module: impl Into<DefId>, tcx: TyCtxt<'_>, ) -> bool

Returns true if an item with this visibility is accessible from the given module.

Source

pub fn is_at_least( self, vis: Visibility<impl Into<DefId>>, tcx: TyCtxt<'_>, ) -> bool

Returns true if this visibility is at least as accessible as the given visibility

Source§

impl Visibility

Source

pub fn to_string(self, def_id: LocalDefId, tcx: TyCtxt<'_>) -> String

Trait Implementations

Source§

impl<Id> Clone for Visibility<Id>
where Id: Clone,

Source§

fn clone(&self) -> Visibility<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 for Visibility<Id>
where Id: Debug,

Source§

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

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

impl<Id, __D> Decodable<__D> for Visibility<Id>
where __D: SpanDecoder, Id: Decodable<__D>,

Source§

fn decode(__decoder: &mut __D) -> Visibility<Id>

Source§

impl<Id, __E> Encodable<__E> for Visibility<Id>
where __E: SpanEncoder, Id: Encodable<__E>,

Source§

fn encode(&self, __encoder: &mut __E)

Source§

impl<Id> Hash for Visibility<Id>
where Id: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'__ctx, Id> HashStable<StableHashingContext<'__ctx>> for Visibility<Id>
where Id: HashStable<StableHashingContext<'__ctx>>,

Source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher<SipHasher128>, )

Source§

impl<Id> PartialEq for Visibility<Id>
where Id: PartialEq,

Source§

fn eq(&self, other: &Visibility<Id>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Id> Copy for Visibility<Id>
where Id: Copy,

Source§

impl<Id> Eq for Visibility<Id>
where Id: Eq,

Source§

impl<Id> StructuralPartialEq for Visibility<Id>