Generic Type Variable Bound
在 rust 中,泛型变量 T
是 &T
和 &mut T
的超集,而 &T
和 &mut T
是不相交集。
Type Variable | Examples |
---|---|
T |
i32 , &i32 , &mut i32 , &&i32 , &mut &mut i32 |
&T |
&i32 , && i32 , &&mut i32 |
&mut T |
&mut i32 , &mut &mut i32 , &mut &i32 |
T does not only contains owned types
T, &T, and &mut T are all infinite sets, since it's possible to borrow a type ad-infinitum. T is a superset of both &T and &mut T. &T and &mut T are disjoint sets.[1]