cannot bind generic !mlirtype to memory-only type
Have been playing with Mojo a bit and like it a lot so far. But one area I feel I'm missing out on something is Arrays.
I implemented a simple Array struct using Pointer. Simple and straightforward to implement and fast. However Pointer only works with mlirtype, not my own structs.
One solution is to decorate my struct with
@register_passable("trivial")
, but I feel there might be a more elegant solution. Any tips?5 Replies
Waiting for traits.
It's a common issue that traits will solve.
Thanks, I guess till that time register_passable will have to do.
I'm also curious about arrays... Where is the register_passable documentation?
It is in the "obscure" section: https://docs.modular.com/mojo/programming-manual.html#advancedobscure-mojo-features
Modular Docs - Mojo🔥 programming manual
A tour of major Mojo language features with code examples.
The things to be aware is also that all attributes in your struct need to have register_passable enabled. But at least it works for some prototyping (till we have traits).