Compare commits
6 Commits
main
...
211f23cea4
| Author | SHA1 | Date | |
|---|---|---|---|
| 211f23cea4 | |||
| 1e516bf0a5 | |||
| 03a0a77394 | |||
| bb27bfad41 | |||
| 4d12facc2f | |||
| 1251a6c1b1 |
@@ -17,7 +17,7 @@
|
|||||||
// You can also find solutions to all exercises in the `solutions` git branch.
|
// You can also find solutions to all exercises in the `solutions` git branch.
|
||||||
fn greeting() -> &'static str {
|
fn greeting() -> &'static str {
|
||||||
// TODO: fix me 👇
|
// TODO: fix me 👇
|
||||||
"I'm ready to __!"
|
"I'm ready to learn Rust!"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Your solutions will be automatically verified by a set of tests.
|
// Your solutions will be automatically verified by a set of tests.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// partner in this course and it'll often guide you in the right direction!
|
// partner in this course and it'll often guide you in the right direction!
|
||||||
//
|
//
|
||||||
// The input parameters should have the same type of the return type.
|
// The input parameters should have the same type of the return type.
|
||||||
fn compute(a, b) -> u32 {
|
fn compute(a: u32, b: u32) -> u32 {
|
||||||
// Don't touch the function body.
|
// Don't touch the function body.
|
||||||
a + b * 2
|
a + b * 2
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,4 @@ mod tests {
|
|||||||
fn case() {
|
fn case() {
|
||||||
assert_eq!(compute(1, 2), 5);
|
assert_eq!(compute(1, 2), 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fn intro() -> &'static str {
|
fn intro() -> &'static str {
|
||||||
// TODO: fix me 👇
|
// TODO: fix me 👇
|
||||||
"I'm ready to __!"
|
"I'm ready to build a calculator in Rust!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fn compute(a: u32, b: u32) -> u32 {
|
fn compute(a: u32, b: u32) -> u32 {
|
||||||
// TODO: change the line below to fix the compiler error and make the tests pass.
|
// TODO: change the line below to fix the compiler error and make the tests pass.
|
||||||
a + b * 4u8
|
a + b * 4u32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
pub fn speed(start: u32, end: u32, time_elapsed: u32) -> u32 {
|
pub fn speed(start: u32, end: u32, time_elapsed: u32) -> u32 {
|
||||||
// TODO: define a variable named `distance` with the right value to get tests to pass
|
// TODO: define a variable named `distance` with the right value to get tests to pass
|
||||||
// Do you need to annotate the type of `distance`? Why or why not?
|
// Do you need to annotate the type of `distance`? Why or why not?
|
||||||
|
let distance: u32 = end - start;
|
||||||
// Don't change the line below
|
// Don't change the line below
|
||||||
distance / time_elapsed
|
distance / time_elapsed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/// Return `true` if `n` is even, `false` otherwise.
|
/// Return `true` if `n` is even, `false` otherwise.
|
||||||
fn is_even(n: u32) -> bool {
|
fn is_even(n: u32) -> bool {
|
||||||
todo!()
|
n % 2 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user