if ncnd.location == Position::new(0,0) {
self.wander();
return
}
used to get the error, however how do i create a safety net to enter the if scope if uninit?
pretty much does ncnd have a value? -> no: wander
if ncnd.location == Position::new(0,0) {
self.wander();
return
}
used to get the error, however how do i create a safety net to enter the if scope if uninit?
pretty much does ncnd have a value? -> no: wander
Without more context, it's hard to tell what you want.
If ncnd.location would be an Option<T> you could check for it to be None instead of for it being a magic default value.
let mut ncnd: &mut Plant;
for candidate in cinr {
let ccd: f32 = distance_eucl(&self.location, &candidate.location);
if ccd < shortest {
shortest = ccd;
ncnd = candidate;
}
}
so i should make ncnd an option?
if so, thank you i didnt think of that