Skip to main content

Keyword

Enum Keyword 

Source
pub enum Keyword {
Show 70 variants Auto, Break, Case, Char, Const, Continue, Default, Do, Double, Else, Enum, Extern, Float, For, Goto, If, Inline, Int, Long, Register, Restrict, Return, Short, Signed, Sizeof, Static, Struct, Switch, Typedef, Union, Unsigned, Void, Volatile, While, Bool, Complex, Imaginary, Alignas, Alignof, Atomic, Generic, Noreturn, StaticAssert, ThreadLocal, BitInt, BoolName, True, False, Nullptr, Typeof, TypeofUnqual, Constexpr, StaticAssertName, AlignofName, AlignasName, ThreadLocalName, Attribute, Extension, AlignofGnu, TypeofGnu, TypeofUnqualGnu, Asm, Label, AutoType, ThreadGnu, Int128, RealGnu, ImagGnu, InlineGnu, RestrictGnu,
}
Expand description

A C99 keyword.

Variants§

§

Auto

§

Break

§

Case

§

Char

§

Const

§

Continue

§

Default

§

Do

§

Double

§

Else

§

Enum

§

Extern

§

Float

§

For

§

Goto

§

If

§

Inline

§

Int

§

Long

§

Register

§

Restrict

§

Return

§

Short

§

Signed

§

Sizeof

§

Static

§

Struct

§

Switch

§

Typedef

§

Union

§

Unsigned

§

Void

§

Volatile

§

While

§

Bool

§

Complex

§

Imaginary

§

Alignas

§

Alignof

§

Atomic

§

Generic

§

Noreturn

§

StaticAssert

§

ThreadLocal

§

BitInt

§

BoolName

§

True

§

False

§

Nullptr

§

Typeof

§

TypeofUnqual

§

Constexpr

§

StaticAssertName

§

AlignofName

§

AlignasName

§

ThreadLocalName

§

Attribute

__attribute__, __attribute

§

Extension

__extension__

§

AlignofGnu

__alignof__, __alignof

§

TypeofGnu

__typeof__, __typeof, and typeof in a GNU dialect

§

TypeofUnqualGnu

__typeof_unqual__

§

Asm

__asm__, __asm, and asm in a GNU dialect

§

Label

__label__

§

AutoType

__auto_type

§

ThreadGnu

__thread

§

Int128

__int128

A type specifier of its own, which signed and unsigned combine with; the __int128_t and __uint128_t spellings are typedef names the compiler owns rather than keywords, exactly as they are in GCC.

§

RealGnu

__real__, __real

§

ImagGnu

__imag__, __imag

§

InlineGnu

__inline__, __inline

A variant of its own because the plain spelling is C99’s and c89! gates it, while this one — being reserved — is available everywhere.

§

RestrictGnu

__restrict__, __restrict; see Keyword::InlineGnu.

Implementations§

Source§

impl Keyword

Source

pub fn as_str(self) -> &'static str

The spelling of this keyword in C source.

Source

pub fn is_gnu(self) -> bool

Whether this keyword is one of the GNU spellings the preprocessor introduces; see the variants’ own documentation.

Source

pub fn since(self) -> Standard

The revision that made this spelling a keyword.

The C11 keywords are recognised in every mode — they are reserved identifiers in C99, so nothing legal can be broken by it, and the parser’s “requires C11 or later” is a better answer than a syntax error. The C23 ones are not: they are ordinary identifiers before C23, and <stdbool.h>’s #define bool _Bool depends on it.

The four C99 added — inline, restrict, _Bool and _Complex (with _Imaginary beside it) — are recognised in every mode for the same reason the C11 ones are, and gated where they are parsed; everything else has been a keyword since C89.

Source

pub fn from_str(s: &str, standard: Standard) -> Option<Keyword>

Looks a keyword up by spelling, honouring the language standard.

Trait Implementations§

Source§

impl Clone for Keyword

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Keyword

Source§

impl Debug for Keyword

Source§

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

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

impl Eq for Keyword

Source§

impl Hash for Keyword

Source§

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

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 PartialEq for Keyword

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Keyword

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.