Rust

From Wiki :-)
Revision as of 18:37, 5 November 2017 by Savoundg (talk | contribs)
Jump to navigation Jump to search

Ownership

In Rust, unlike C++, by default, on a function call, the ownership of parameters is transferred; the copy should be explicit (.clone()).

Borrowing

Shared borrow

Cannot mutate while shared.

Mutable borrow

Cannot access while borrowed.

Can access the mutable borrowed variable.

Lifetime reference

Traits

Marker traits

  • trait Send { }: Safe to send between thread: String, u32, Arc<String>
  • trait Copy { }: Safe to memcpy: u32, f32,