Enum Safety

pub enum Safety

Safe, unsafe or default.

Variants

Safe(Safe)

The item is qualified as safe.

Unsafe(Unsafe)

The item is qualified as unsafe.

Default

The item is not qualified either way.

Implementations

impl Safety

fn parse_safe_or_unsafe(input: ParseStream<'_>) -> Result<Self>

Parses safe, unsafe, or default (neither).

This is appropriate for matching the syntax of extern blocks, in which functions are unsafe by default and require safe otherwise.

unsafe extern "C" {
    fn implicitly_unsafe();
    unsafe fn explicitly_unsafe();
    safe fn explicitly_safe();
}
fn parse_unsafe_only(input: ParseStream<'_>) -> Result<Self>

Parses unsafe or default (nothing).

This is appropriate for functions not within an extern block, which are safe by default and cannot be explicitly marked safe.

fn implicitly_safe() {}
unsafe fn explicitly_unsafe() {}

// safe fn explicitly_safe() {}
// ^^^^ ERROR: items outside of `unsafe extern { }` cannot be declared with `safe` safety qualifier

Trait Implementations

impl Clone for Safety

fn clone(&self) -> Self

impl Default for Safety

fn default() -> Self

impl ToTokens for Safety

fn to_tokens(&self, tokens: &mut TokenStream)

Auto Trait Implementations

impl !Send for Safety

impl !Sync for Safety

impl Freeze for Safety

impl RefUnwindSafe for Safety

impl Unpin for Safety

impl UnsafeUnpin for Safety

impl UnwindSafe for Safety

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Safety where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Safety where T: ?Sized,

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

impl<T> CloneToUninit for Safety where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Safety

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Spanned for Safety where T: Spanned + ?Sized,

fn span(&self) -> Span

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Safety where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Safety where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>