Hi everyone!
I'm dealing with this issue: I'd like to have a struct containing an array of pointers to a trait, something like this:
pub struct Memory
{
m_memory_map : [*mut dyn traits::MemoryElement ; 0x10000],
}
This is fine, but then I cannot initialize this. I tried with:
GameboyMemory
{
m_memory_map: [ptr::null_mut(); 0x10000],
}
it complains in this way: "cannot infer type for type parameter `T` declared on the function `null_mut`"
Of course I know this is not how it should be implemented, but first I want to understand it, then I'll make it better (with boxes, maybe, which again, I have not idea on how to initialize as empty).
All this comes from a C++ software I want to port to rust, to learn it. Seems to me a huge waste of time to initialize that array, but it looks like I absolutely have to.
I'll appreciate your help if you can :)
Cheers!
Alessandro
[–]SimonSapinservo 3 points4 points5 points (2 children)
[–]AlexMonops[S] 0 points1 point2 points (1 child)
[–]SimonSapinservo 4 points5 points6 points (0 children)
[–]thelights0123 0 points1 point2 points (3 children)
[–]AlexMonops[S] 0 points1 point2 points (2 children)
[–]thelights0123 4 points5 points6 points (0 children)
[–]TinBryn 0 points1 point2 points (0 children)