Skip to main content

Builtin

Enum Builtin 

Source
pub enum Builtin {
    File,
    FileName,
    BaseFile,
    Line,
    IncludeLevel,
    Counter,
}
Expand description

A predefined macro whose value is a question rather than a replacement list.

__FILE__ and its relatives cannot be written as a body, because what they stand for depends on where they are used rather than on what the target is. GCC calls these builtin macros and answers them while expanding, and this is the same arrangement: the table holds the name and which question it is, and crate::expand asks the source map when it meets one. Everything else about them is ordinary, so #ifdef __FILE__ is true, #undef __FILE__ works, and redefining one warns the way redefining anything else does.

Variants§

§

File

__FILE__, the file the use is in, spelled as a string literal.

§

FileName

__FILE_NAME__, the same file with the directories taken off.

§

BaseFile

__BASE_FILE__, the file at the bottom of the include stack.

§

Line

__LINE__, the line the use is on.

§

IncludeLevel

__INCLUDE_LEVEL__, how many #include directives deep the use is.

§

Counter

__COUNTER__, a number that is different every time it is expanded.

Implementations§

Source§

impl Builtin

Source

pub const ALL: [(&'static str, Builtin); 6]

Every builtin macro and its spelling.

One list, so that the set the preprocessor defines and the set -dM prints cannot drift apart.

Trait Implementations§

Source§

impl Clone for Builtin

Source§

fn clone(&self) -> Builtin

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 Builtin

Source§

impl Debug for Builtin

Source§

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

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

impl Eq for Builtin

Source§

impl PartialEq for Builtin

Source§

fn eq(&self, other: &Builtin) -> 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 Builtin

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.