You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).
Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066
Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.
Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
0 commit comments