-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cf0288
commit 9df8e00
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pub fn create_closures() -> ( | ||
impl Fn(i32, i32) -> i32, | ||
impl Fn(i32, i32) -> i32, | ||
impl Fn(i32, i32) -> i32, | ||
) { | ||
let add_closure = |a, b| { | ||
// Step 1: Implement here | ||
a + b | ||
}; | ||
|
||
// Step 2: | ||
// Create the `subtract_closure` closure that subtracts two `i32` values. | ||
let subtract_closure = |a, b| a - b; | ||
// Step 3: | ||
// Create the `multiply_closure` closure that multiplies two `i32` values. | ||
let multiply_closure = |a, b| a * b; | ||
|
||
(add_closure, subtract_closure, multiply_closure) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pub fn check_number_sign(number: i32) -> String { | ||
// Return `"positive"` if the number is positive. | ||
// Return `"negative"` if the number is negative. | ||
// Return `"zero"` if the number is zero. | ||
if number > 0 { | ||
String::from("positive") | ||
} else if number < 0 { | ||
String::from("negative") | ||
} else { | ||
String::from("zero") | ||
} | ||
} |