Learning Rust and ran into an unexpected stack overflow.
Sorry if this is a dumb question but i've just started learning rust and today was the first time that I needed to use fmt::Display. The code compiles without any errors but it hits a stack overflow almost instantly on runtime. I've dug around a bit online but all of the resources I found for this kind of error all either flew over my head or were unrelated. As far as I can tell i've pretty much just implimented the Rust by Example implimentation so i'm a little unsure as to what could even be going wrong.
Apologies/thanks in advance.
use std::fmt;
fn main() {
let c = Cave{map: [[[false; 512]; 512]; 512]};
println!("{}", c);
}
#[derive(Debug)]
struct Cave{
map: [[[bool; 512]; 512]; 512]
}
impl fmt::Display for Cave {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({:?})", self)
}
}