Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.
let score = scores.get(&String::from("Bleu"));
let mut v = Vec::new();
v.push(5);
v.push(6);
let s1 = String::from("Hello, ");
let s2 = String::from("world!");
let s3 = s1 + &s2; // s1 est déplacé ici
let v: Vec<i32> = Vec::new();
let v2 = vec![1, 2, 3];
let s = String::new();
let s = "texte initial".to_string();
let s = String::from("texte initial");
use std::collections::HashMap;
let mut scores = HashMap::new();
scores.insert(String::from("Bleu"), 10);
let v = vec![100, 32, 57];
for i in &v {
println!("{}", i);
}
for (cle, valeur) in &scores {
println!("{}: {}", cle, valeur);
}
let v = vec![1, 2, 3];
let troisieme: &i32 = &v[2];
let troisieme_safe: Option<&i32> = v.get(2);
let mut s = String::from("foo");
s.push_str("bar");
scores.insert(String::from("Bleu"), 25);
scores.entry(String::from("Jaune")).or_insert(50);