File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
crates/rs-101/basic/src/bin Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let mut vec = vec ! [ "Java" , "Rust" , "Python" ] ;
3
+ for str in vec. iter_mut ( ) {
4
+ let & mut cs = str;
5
+ match cs {
6
+ "Rust" => {
7
+ * str = "Niubility" ;
8
+ println ! ( "{}" , str ) ;
9
+ } ,
10
+ _ => println ! ( "{}" , str ) ,
11
+ }
12
+ }
13
+
14
+ println ! ( "{:?}" , vec) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let mut vec = vec ! [ "Java" . to_string( ) , "Rust" . to_string( ) , "Python" . to_string( ) ] ;
3
+ let mut vi = vec. iter_mut ( ) ;
4
+
5
+ while let Some ( cs) = vi. next ( ) {
6
+ match cs. as_str ( ) {
7
+ "Rust" => {
8
+ * cs = "Niubility" . to_string ( ) ;
9
+ println ! ( "{}" , cs) ;
10
+ } ,
11
+ _ => println ! ( "{}" , cs) ,
12
+ }
13
+ }
14
+
15
+ println ! ( "{:?}" , vec) ;
16
+ }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let mut vec = [ "Java" . to_string ( ) , "Rust" . to_string ( ) , "Python" . to_string ( ) ] ;
3
+ for mut str in vec. iter_mut ( ) {
4
+ match str. as_str ( ) {
5
+ "Rust" => {
6
+ * str = "Niubility" . to_string ( ) ;
7
+ println ! ( "{}" , str ) ;
8
+ } ,
9
+ _ => println ! ( "{}" , str ) ,
10
+ }
11
+ }
12
+
13
+ println ! ( "{:?}" , vec) ;
14
+ }
You can’t perform that action at this time.
0 commit comments