pub(crate) fn to_worker_sdk(&self) -> (Worker_Constraint, Box<[Worker_Constraint]>) {
        // First descend the tree and count how many constraints we need in the Vec.
        let size = self.constraint_len_recursive();

        // Allocate the vector required to store this data. Use a dummy placeholder for the data.
        let dummy_constraint = Worker_Constraint {
            constraint_type: Worker_ConstraintType_WORKER_CONSTRAINT_TYPE_ENTITY_ID as u8,
            constraint: Worker_Constraint_Union {
                entity_id_constraint: Worker_EntityIdConstraint { entity_id: 0 },
            },
        };
        let underlying_data = vec![dummy_constraint; size as usize];
        let mut data = underlying_data.into_boxed_slice();

        // Now go down the tree again, this time creating pointers to the correct vector element.
        // Also fill the vector with the correct data as we go down the tree as well.
        let (constraint, _) = self.to_worker_sdk_recursive(&mut data, 0);

        // Return the constraint and the underlying data.
        (constraint, data)
    }
// The general strategy with this is to pre-allocate the memory required to store all elements
// in the constraint tree. This means that we can insert points to indices in the array which
// will contain the correct data. This also means that the array lifetime should live as long
// as the struct passed down to the C layer.
The general strategy with this is to pre-allocate the memory required to store all elements
in the constraint tree. This means that we can insert points to indices in the array which
will contain the correct data. This also means that the array lifetime should live as long
as the struct passed down to the C layer.
The general strategy with this is to pre - allocate the memory required to store all elements in the constraint tree . This means that we can insert points to indices in the array which will contain the correct data . This also means that the array lifetime should live as long as the struct passed down to the C layer .
pub(crate) fn to_worker_sdk(&self) -> (Worker_Constraint, Box<[Worker_Constraint]>) {
        // First descend the tree and count how many constraints we need in the Vec.
        let size = self.constraint_len_recursive();
        // Allocate the vector required to store this data. Use a dummy placeholder for the data.
        let dummy_constraint = Worker_Constraint {
            constraint_type: Worker_ConstraintType_WORKER_CONSTRAINT_TYPE_ENTITY_ID as u8,
            constraint: Worker_Constraint_Union {
                entity_id_constraint: Worker_EntityIdConstraint { entity_id: 0 },
            },
        };
        let underlying_data = vec![dummy_constraint; size as usize];
        let mut data = underlying_data.into_boxed_slice();
        // Now go down the tree again, this time creating pointers to the correct vector element.
        // Also fill the vector with the correct data as we go down the tree as well.
        let (constraint, _) = self.to_worker_sdk_recursive(&mut data, 0);
        // Return the constraint and the underlying data.
        (constraint, data)
    }
pub ( crate ) fn to_worker_sdk ( & self ) -> ( Worker_Constraint , Box < [ Worker_Constraint ] > ) { // First descend the tree and count how many constraints we need in the Vec. let size = self . constraint_len_recursive ( ) ; // Allocate the vector required to store this data. Use a dummy placeholder for the data. let dummy_constraint = Worker_Constraint { constraint_type : Worker_ConstraintType_WORKER_CONSTRAINT_TYPE_ENTITY_ID as u8 , constraint : Worker_Constraint_Union { entity_id_constraint : Worker_EntityIdConstraint { entity_id : 0 } , } , } ; let underlying_data = vec ! [ dummy_constraint size as usize ] ; let mut data = underlying_data . into_boxed_slice ( ) ; // Now go down the tree again, this time creating pointers to the correct vector element. // Also fill the vector with the correct data as we go down the tree as well. let ( constraint , _ ) = self . to_worker_sdk_recursive ( & mut data , 0 ) ; // Return the constraint and the underlying data. ( constraint , data ) }
The general strategy with this is to pre-allocate the memory required to store all elements
in the constraint tree.
The general strategy with this is to pre - allocate the memory required to store all elements in the constraint tree .
&self
&self