Skip to main content

Keyword

Enum Keyword 

Source
pub enum Keyword {
Show 74 variants Auto, Break, Case, Char, Const, Continue, Default, Do, Double, Else, Enum, Extern, Float, For, Goto, If, Int, Long, Register, Return, Short, Signed, Sizeof, Static, Struct, Switch, Typedef, Union, Unsigned, Void, Volatile, While, Inline, Restrict, Bool, Complex, Imaginary, Alignas, Alignof, Atomic, Generic, Noreturn, StaticAssert, ThreadLocal, BitInt, Decimal32, Decimal64, Decimal128, Float16, Float32, Float64, Float128, Float32x, Float64x, Float128x, Constexpr, False, Nullptr, True, Typeof, TypeofUnqual, Asm, Attribute, AutoType, GnuAlignof, Extension, Imag, Real, Int128, Label, BuiltinOffsetof, BuiltinChooseExpr, BuiltinTypesCompatibleP, BuiltinVaArg,
}
Expand description

A keyword, meaning a spelling the grammar knows rather than a name a program chose.

One variant per meaning, not per spelling. __inline__ and inline are the same keyword because they are the same declaration specifier, and a parser that had to know which of them was written would be carrying the difference all the way to the AST for nothing. Where two spellings mean genuinely different things they stay apart: __alignof__ is Keyword::GnuAlignof rather than Keyword::Alignof, because GNU’s asks for the alignment the target prefers and C’s asks for the one the ABI requires, and on i386 they disagree about double.

Variants§

§

Auto

auto.

§

Break

break.

§

Case

case.

§

Char

char.

§

Const

const, and the GNU spelling __const.

§

Continue

continue.

§

Default

default.

§

Do

do.

§

Double

double.

§

Else

else.

§

Enum

enum.

§

Extern

extern.

§

Float

float.

§

For

for.

§

Goto

goto.

§

If

if.

§

Int

int.

§

Long

long.

§

Register

register.

§

Return

return.

§

Short

short.

§

Signed

signed, and the GNU spelling __signed__.

§

Sizeof

sizeof.

§

Static

static.

§

Struct

struct.

§

Switch

switch.

§

Typedef

typedef.

§

Union

union.

§

Unsigned

unsigned.

§

Void

void.

§

Volatile

volatile, and the GNU spelling __volatile__.

§

While

while.

§

Inline

inline, from C99, and the GNU spelling __inline__.

§

Restrict

restrict, from C99, and the GNU spelling __restrict__.

§

Bool

_Bool, and bool from C23.

§

Complex

_Complex, and the GNU spelling __complex__.

§

Imaginary

_Imaginary.

§

Alignas

_Alignas, and alignas from C23.

§

Alignof

_Alignof, and alignof from C23.

§

Atomic

_Atomic.

§

Generic

_Generic.

§

Noreturn

_Noreturn.

§

StaticAssert

_Static_assert, and static_assert from C23.

§

ThreadLocal

_Thread_local, thread_local from C23, and the GNU spelling __thread.

§

BitInt

_BitInt.

§

Decimal32

_Decimal32.

§

Decimal64

_Decimal64.

§

Decimal128

_Decimal128.

§

Float16

_Float16.

§

Float32

_Float32.

§

Float64

_Float64.

§

Float128

_Float128.

§

Float32x

_Float32x.

§

Float64x

_Float64x.

§

Float128x

_Float128x.

§

Constexpr

constexpr, from C23.

§

False

false, from C23.

§

Nullptr

nullptr, from C23.

§

True

true, from C23.

§

Typeof

typeof, from C23 and from the GNU dialects, and the spelling __typeof__.

§

TypeofUnqual

typeof_unqual, from C23, and the spelling __typeof_unqual__.

§

Asm

asm, in the GNU dialects, and the spelling __asm__.

§

Attribute

__attribute__.

§

AutoType

__auto_type, which is not auto: it deduces from an initialiser in every dialect.

§

GnuAlignof

__alignof__, which asks for the preferred alignment rather than the required one.

§

Extension

__extension__, which turns off the pedantic diagnostics for one expression.

§

Imag

__imag__.

§

Real

__real__.

§

Int128

__int128.

§

Label

__label__, which declares a local label in a statement expression.

§

BuiltinOffsetof

__builtin_offsetof, which is syntax rather than a function because it takes a type.

§

BuiltinChooseExpr

__builtin_choose_expr.

§

BuiltinTypesCompatibleP

__builtin_types_compatible_p.

§

BuiltinVaArg

__builtin_va_arg.

Implementations§

Source§

impl Keyword

Source

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

The spelling to print in a diagnostic, which is the standard one where there is one.

This walks the table, because it is only ever reached while writing a message and a second array indexed by the enum would be one more place for the two to disagree.

Trait Implementations§

Source§

impl Clone for Keyword

Source§

fn clone(&self) -> Keyword

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

Source§

fn cmp(&self, other: &Keyword) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Keyword

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Keyword

Source§

fn partial_cmp(&self, other: &Keyword) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= 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, <T as TryFrom<U>>::Error>

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.