Advertisement
fcamuso

Un assaggio di Rust: video 5

Nov 27th, 2022
1,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.52 KB | None | 0 0
  1.  
  2. fn valutaPopolarita(ling: &mut String) -> String
  3. {
  4.     //*ling = "modificata".to_string();
  5.  
  6.     if ling == "Rust"
  7.       {"in aumento".to_string()}
  8.     else
  9.       {"stabile".to_string()}      
  10. }
  11.  
  12. fn main() {
  13.    
  14.     let mut linguaggio = "Rust".to_string();
  15.    
  16.     print!("{} ", linguaggio);
  17.     println!("{}", valutaPopolarita(&mut linguaggio));
  18.  
  19.     let mut s1 = "Occhio al trabocchetto!".to_string();
  20.    
  21.     let s2 = &mut s1;
  22.     s2.truncate(6);
  23.     println!("{}", s2);
  24.  
  25.     print!("{}", s1);
  26.  
  27.    
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement