File tree Expand file tree Collapse file tree 2 files changed +7
-18
lines changed
Expand file tree Collapse file tree 2 files changed +7
-18
lines changed Original file line number Diff line number Diff line change 99// Execute `rustlings hint clippy1` or use the `hint` watch subcommand for a
1010// hint.
1111
12- // I AM NOT DONE
13-
14- use std:: f32;
15-
1612fn main ( ) {
17- let pi = 3.14f32 ;
18- let radius = 5.00f32 ;
19-
20- let area = pi * f32:: powi ( radius, 2 ) ;
13+ const PI : f32 = std:: f32:: consts:: PI ;
14+ let radius = 5.0_f32 ;
15+ let area = PI * radius. powi ( 2 ) ;
2116
22- println ! (
23- "The area of a circle with radius {:.2} is {:.5}!" ,
24- radius, area
25- )
17+ println ! ( "The area of a circle with radius {radius:.2} is {area:.5}!" ) ;
2618}
Original file line number Diff line number Diff line change 11// clippy2.rs
2- //
2+ //
33// Execute `rustlings hint clippy2` or use the `hint` watch subcommand for a
44// hint.
55
6- // I AM NOT DONE
7-
86fn main ( ) {
97 let mut res = 42 ;
10- let option = Some ( 12 ) ;
11- for x in option {
8+ if let Some ( x) = Some ( 12 ) {
129 res += x;
1310 }
14- println ! ( "{}" , res ) ;
11+ println ! ( "{res}" ) ;
1512}
You can’t perform that action at this time.
0 commit comments