Skip to main content

Storage

Enum Storage 

Source
pub enum Storage {
    Automatic,
    Static {
        item_name: String,
        exported: bool,
    },
    ThreadLocal {
        item_name: String,
        exported: bool,
    },
    Extern {
        item_name: String,
    },
}
Expand description

Where an object lives, and how it is generated.

Variants§

§

Automatic

A let binding: a local variable or a parameter.

§

Static

A static mut item: a file-scope variable or a function-local static.

Fields

§item_name: String

The name of the generated Rust item, already made unique.

§exported: bool

Whether the item is pub — true for a file-scope object without static, which C gives external linkage and which Rust code should therefore be able to reach.

§

ThreadLocal

A thread_local! item: an object declared _Thread_local, thread_local or __thread.

C gives it static storage duration and one instance per thread, which is exactly what std::thread_local! provides. The item holds an UnsafeCell<T>, and every access goes through the *mut T its with hands out — valid for as long as the current thread’s copy is, which is the lifetime C promises. It is the third construct whose expansion needs more than core, after variable length arrays and alloca.

Fields

§item_name: String

The name of the generated Rust item, already made unique.

§exported: bool

Whether the item is pub; see Storage::Static.

§

Extern

An object defined outside the translation unit, declared in the expansion’s extern block.

Fields

§item_name: String

The name the symbol has.

Implementations§

Source§

impl Storage

Source

pub fn item_name(&self) -> Option<&str>

The name of the generated item, for the two storage classes that have one of their own.

Source

pub fn is_thread_local(&self) -> bool

Whether this is a thread-local object.

Trait Implementations§

Source§

impl Clone for Storage

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 Debug for Storage

Source§

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

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

impl Eq for Storage

Source§

impl PartialEq for Storage

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 Storage

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.