Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Non-references

The variance of lifetime and type parameters of your own structs is automatically inferred from how you use those parameters in your field. For example if you have a

#![allow(unused)]
fn main() {
struct AllMine<'a, T>(&'a mut T);
}

Then AllMine is covariant in 'a and invariant in T, just like &'a mut T is.