Type | Instant |
---|---|
Int | i32 u32 |
Float | float32 float64 |
Boolean | true false |
Char | 'z' |
stuct
enum
array
tuple
pattern
let && if let && while let
----if
----loop
----while
----for
Each value in Rust has an owner.
There can only be one owner at a time.
When the owner goes out of scope, the value will be dropped.
impl copy trait
>All the integer types, such as u32.
>The Boolean type, bool, with values true and false.
>All the floating-point types, such as f64.
>The character type, char.
>Tuples, if they only contain types that also implement Copy. For example, (i32, i32) implements Copy, but (i32, String) does not.
Reference Rules
>At any given time, you can have either one mutable reference or any number of immutable references.
>References must always be valid.
.generic in struct and enum
stuct <T> People {
name: T,
id: T,
}
.generic in fn
fn <T> get(s: T) -> T{}
fn <T, F> put(s: T) -> F
where
F: FnOnce
{}
Box<dyn trait>