File tree 2 files changed +31
-0
lines changed
Rust/rustifinity/challenges
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ pub fn create_closures ( ) -> (
2
+ impl Fn ( i32 , i32 ) -> i32 ,
3
+ impl Fn ( i32 , i32 ) -> i32 ,
4
+ impl Fn ( i32 , i32 ) -> i32 ,
5
+ ) {
6
+ let add_closure = |a, b| {
7
+ // Step 1: Implement here
8
+ a + b
9
+ } ;
10
+
11
+ // Step 2:
12
+ // Create the `subtract_closure` closure that subtracts two `i32` values.
13
+ let subtract_closure = |a, b| a - b;
14
+ // Step 3:
15
+ // Create the `multiply_closure` closure that multiplies two `i32` values.
16
+ let multiply_closure = |a, b| a * b;
17
+
18
+ ( add_closure, subtract_closure, multiply_closure)
19
+ }
Original file line number Diff line number Diff line change
1
+ pub fn check_number_sign ( number : i32 ) -> String {
2
+ // Return `"positive"` if the number is positive.
3
+ // Return `"negative"` if the number is negative.
4
+ // Return `"zero"` if the number is zero.
5
+ if number > 0 {
6
+ String :: from ( "positive" )
7
+ } else if number < 0 {
8
+ String :: from ( "negative" )
9
+ } else {
10
+ String :: from ( "zero" )
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments