[][src]Struct c2rust_refactor::transform::statics::CollectToStruct

pub struct CollectToStruct {
    pub struct_name: String,
    pub instance_name: String,
}

static_collect_to_struct Command

Usage: static_collect_to_struct STRUCT VAR

Marks: target

Collect marked statics into a single static struct.

Specifically:

  1. Find all statics marked target. For each one, record its name, type, and initializer expression, then delete it.
  2. Generate a new struct definition named STRUCT. For each marked static, include a field of STRUCT with the same name and type as the static.
  3. Generate a new static mut named VAR whose type is STRUCT. Initialize it using the initializer expressions for the marked statics.
  4. For each marked static foo, replace uses of foo with VAR.foo.

Example:

static mut FOO: i32 = 100;
static mut BAR: bool = true;

unsafe fn f() -> i32 {
    FOO
}

After running static_collect_to_struct Globals G, with both statics marked:

struct Globals {
    FOO: i32,
    BAR: bool,
}

static mut G: Globals = Globals {
    FOO: 100,
    BAR: true,
};

unsafe fn f() -> i32 {
    G.FOO
}

Fields

struct_name: Stringinstance_name: String

Trait Implementations

impl Transform for CollectToStruct[src]

fn min_phase(&self) -> Phase[src]

Return the minimum phase at which this transform can operate. See the Phase docs for details. The default is Phase2. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Lone for T[src]

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<E> SpecializationError for E[src]

impl<T> Erased for T[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> MaybeResult for T[src]

impl<'a, T> Captures for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> Make for T[src]

impl<T> Slottable for T[src]