let person_1 = { };
let person_2 = { parent: person_1 };
person_1.child = person_2;
Rust: use std::cell::Cell;
struct Person<'a> {
parent: Option<&'a Person<'a>>,
child: Cell<Option<&'a Person<'a>>>
}
let person_1 = Person {
parent: None,
child: Cell::new(None)
};
let person_2 = Person {
parent: Some(&person_1),
child: Cell::new(None)
};
person_1.child.set(Some(&person_2));
And that's before we start talking about function signatures and traits.
https://en.wikipedia.org/wiki/Loop_invariant
You should think of it as the condition that's true for all iterations, not a one-time event that halts the loop. The loop is short for this:
Which works for both signed and unsigned numbers. It just so happens that for unsigned numbers you can omit the left-hand side of the &&, and for signed numbers you can omit the right-hand side. To support arbitrary lower bounds, you omit neither.