Struct marker_api::ast::Visibility

source ·
#[repr(C)]
pub struct Visibility<'ast> { /* private fields */ }
Expand description

The declared visibility of an item or field.

Note that this is only the syntactic visibility. The item or field might be reexported with a higher visibility, or have a high default visibility.

// An item without a visibility
fn moon() {}

// A public item
pub fn sun() {}

// An item with a restricted scope
pub(crate) fn star() {}

pub trait Planet {
    // An item without a visibility. But it still has the semantic visibility
    // of `pub` as this is inside a trait declaration.
    fn mass();
}

Implementations§

source§

impl<'ast> Visibility<'ast>

source

pub fn span(&self) -> Option<&Span<'ast>>

The Span of the visibility, if it has been declared.

source

pub fn semantics(&self) -> &Visibility<'ast>

This function returns the semantic representation for the Visibility of this item. That visibility can be used to check if the item is public or restricted to specific modules.

Trait Implementations§

source§

impl<'ast> Debug for Visibility<'ast>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'ast> RefUnwindSafe for Visibility<'ast>

§

impl<'ast> Send for Visibility<'ast>

§

impl<'ast> Sync for Visibility<'ast>

§

impl<'ast> Unpin for Visibility<'ast>

§

impl<'ast> UnwindSafe for Visibility<'ast>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.