Function toManaged [src]
The result is an independent resource which is managed by the caller.
Prototype
pub fn toManaged(self: Const, allocator: Allocator) Allocator.Error!Managed
Parameters
self: Const
allocator: Allocator
Source
pub fn toManaged(self: Const, allocator: Allocator) Allocator.Error!Managed {
const limbs = try allocator.alloc(Limb, @max(Managed.default_capacity, self.limbs.len));
@memcpy(limbs[0..self.limbs.len], self.limbs);
return Managed{
.allocator = allocator,
.limbs = limbs,
.metadata = if (self.positive)
self.limbs.len & ~Managed.sign_bit
else
self.limbs.len | Managed.sign_bit,
};
}