pub struct BoxTransformer;Expand description
Transformer for converting malloc patterns to Box::new().
Implementations§
Source§impl BoxTransformer
impl BoxTransformer
Sourcepub fn transform_malloc_to_box(
&self,
_malloc_expr: &HirExpression,
pointee_type: &HirType,
) -> HirExpression
pub fn transform_malloc_to_box( &self, _malloc_expr: &HirExpression, pointee_type: &HirType, ) -> HirExpression
Transform a malloc expression into a Box::new() expression.
Converts patterns like:
malloc(sizeof(T))→Box::new(T::default())malloc(size)→Box::new(T::default())
For now, we generate a default-initialized Box since we don’t have sizeof analysis yet. This will be enhanced in future phases.
Sourcepub fn transform_statement(
&self,
stmt: &HirStatement,
_candidate: &BoxCandidate,
) -> HirStatement
pub fn transform_statement( &self, stmt: &HirStatement, _candidate: &BoxCandidate, ) -> HirStatement
Transform a statement containing malloc into one using Box::new().
Takes a VariableDeclaration or Assignment with malloc and transforms it. Converts both the malloc expression AND the variable type from Pointer to Box.
Trait Implementations§
Source§impl Clone for BoxTransformer
impl Clone for BoxTransformer
Source§fn clone(&self) -> BoxTransformer
fn clone(&self) -> BoxTransformer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoxTransformer
impl Debug for BoxTransformer
Auto Trait Implementations§
impl Freeze for BoxTransformer
impl RefUnwindSafe for BoxTransformer
impl Send for BoxTransformer
impl Sync for BoxTransformer
impl Unpin for BoxTransformer
impl UnwindSafe for BoxTransformer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more