Mohamed Mabrouk
Mohamed Mabrouk
MModular
Created by Mohamed Mabrouk on 5/19/2024 in #community-showcase
Blazeseq: Toolkit for FASTQ parsing
2 replies
MModular
Created by Mohamed Mabrouk on 3/6/2024 in #questions
In-place replacement of struct fields
Hey all, I was wondering if someone has a away of changing the underlying data of a tensor in a struct at run time.
struct IOStream
var source: Tensor
fn __init__(inout self):
self.source = Tensor[DType.int8](100)

fn _resize(inout self):
self.source = Tensor[DType.int8](50) # fails as self.source is static
struct IOStream
var source: Tensor
fn __init__(inout self):
self.source = Tensor[DType.int8](100)

fn _resize(inout self):
self.source = Tensor[DType.int8](50) # fails as self.source is static
Can you instead change the pointer of the underlying data of self.sourceto another pointer, doing in place change of the tensor? similar to rust's mem::replace Edit1: Intrestingly the error does not appear with mojo run but when the binary is build with mojo build and then ./path/to/binary
4 replies