Skip to main content

Source

Struct Source 

Source
pub struct Source {
    pub map: SourceMap,
    pub root: FileId,
    pub mode: InputMode,
    /* private fields */
}
Expand description

The captured macro input: a SourceMap plus the id of the root file.

Fields§

§map: SourceMap

All source files seen so far.

§root: FileId

The file holding the macro’s own C text.

§mode: InputMode

How the root file was captured.

Implementations§

Source§

impl Source

Source

pub fn unit_id(&self) -> u64

A number that identifies this macro invocation.

Two c99! blocks in one Rust module generate items into the same namespace, so every synthetic name — the module holding the extern block, the mangling of a function-local static, the name given to an anonymous struct — has to carry something that tells the two apart. This is that something: a hash of where the invocation is (its file, line and column) together with its text, which makes it deterministic across compilations of the same code, unique between invocations, and stable enough for a snapshot test to record.

Source§

impl Source

Source

pub fn text(&self) -> &str

The root file’s C text.

Source

pub fn base(&self) -> Pos

The global offset of the root file’s first byte.

Source

pub fn root_range(&self) -> SourceRange

The range covering the whole root file.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Source

§

impl !Send for Source

§

impl !Sync for Source

§

impl !UnwindSafe for Source

§

impl Freeze for Source

§

impl Unpin for Source

§

impl UnsafeUnpin for Source

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> 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, 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.