rust读书笔记
type
unit type
()
, whose only possible value is an empty tuple: ()
empty type
!
, cannot be instantiated, it is different from the () type, which has exactly one possible value
The main advantage of this type is that it can be cast to any other type 1
2
3fn foo() -> ! {
panic!("This call never returns.");
}
custom type
- struct
- unit struct a generic type struct
1
struct UnitStruct;