Skip to content

my exercises about Rust on 2024!Let's Go!!!!!!!!!!!

Notifications You must be signed in to change notification settings

V4yukon/Rust-2024

Repository files navigation

Some Concepts

1.type system


1.1 Scalar Types

Type Instant
Int i32 u32
Float float32 float64
Boolean true false
Char 'z'

1.2 Compound Types

stuct
enum
array tuple

2.variables

pattern

let && if let && while let

3.loop

----if
----loop
----while
----for

4.ownership

4.1 ownership

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.
alt text

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.

4.2 borrow and reference

alt text

Reference Rules
>At any given time, you can have either one mutable reference or any number of immutable references.
>References must always be valid.

5.generic

.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
{}

.

6.trait

  Box<dyn trait>

7.lifetime


8.closure


9.smart pointer


10.about core && alloc && std crates

About

my exercises about Rust on 2024!Let's Go!!!!!!!!!!!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published