pub enum Safety {
Safe(Safe),
Unsafe(Unsafe),
Default,
}Expand description
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§
Source§impl Safety
impl Safety
Sourcepub fn parse_safe_or_unsafe(input: ParseStream<'_>) -> Result<Self>
pub 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();
}Sourcepub fn parse_unsafe_only(input: ParseStream<'_>) -> Result<Self>
pub 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 qualifierTrait Implementations§
impl Eq for Safety
Available on crate feature
full only.Source§impl ToTokens for Safety
impl ToTokens for Safety
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Returns a
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.