RUST Flashcards
costrutti particolari di rust (9 cards)
Create an array
let arr: [i32; 5] = [1, 2, 3, 4, 5];
Create a string
Only to read -> let s: &str;
To modify -> let s: String;
(String has string modification methods such as character insertion, string insertion, removal, clearing, contains, from str to String,…)
Multi dimensional array
let array: [[i64; 6] ;2];
Pass reference read-only
fn(&var)
Pass reference to modify, without losing ownership
fn(&mut var)
Passing and returning arrays
let mut arr: [i32, 5];
fn(arr)
fn function (mut arr: [i32 ; 5]) -> [i32 ; 5]{
return arr;
}
How create new asyncronous channel?
let (tx, rx) = mpsc::channel()
Cosa fa clone?
Prende self come argomento &self e ne ritorna il valore self