File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ cargo clippy
104104cargo fmt --check
105105
106106# rust-analyzer can analyze the project
107- rust-analyzer analysis-stats /path/to/zero2prod
107+ rust-analyzer analysis-stats .
108108```
109109
110110From inside Vim:
@@ -128,6 +128,7 @@ From inside Vim:
128128| ` [d ` / ` ]d ` | Previous / next diagnostic |
129129| ` <leader>d ` | Show current diagnostic |
130130| ` :LspDiagShow ` | Open quickfix list with all diagnostics |
131+ | ` :LspDiagCurrent ` | Get info on the highlighted error |
131132
132133## Hello, World! Why Rust?
133134
Original file line number Diff line number Diff line change 1+ use std:: env;
2+ use std:: str:: FromStr ;
3+
14fn main ( ) {
2- println ! ( "Hello, world!" ) ;
3- println ! ( "-3 to the power of 2 is:" ) ;
4- println ! ( "{}" , power( -3 , 2 ) ) ;
5+ println ! ( "Hello, maths powers!" ) ;
6+
7+ let mut numbers = Vec :: new ( ) ;
8+ for arg in env:: args ( ) . skip ( 1 ) {
9+ numbers. push ( i64:: from_str ( & arg) . expect ( "error parsing arg" ) ) ;
10+ }
11+
12+ if numbers. is_empty ( ) {
13+ eprintln ! ( "Usage: powers NUMBER EXP" ) ;
14+ std:: process:: exit ( 1 ) ;
15+ }
16+ if numbers. len ( ) > 2 {
17+ eprintln ! ( "Usage: powers NUMBER EXP" ) ;
18+ eprintln ! ( "Error: only two values expected saw {}" , numbers. len( ) ) ;
19+ std:: process:: exit ( 1 ) ;
20+ }
21+
22+ println ! ( "{}" , power( numbers[ 0 ] , numbers[ 1 ] ) ) ;
523}
624
725fn power ( base : i64 , n : i64 ) -> i64 {
You can’t perform that action at this time.
0 commit comments