This commit is contained in:
Leonardo Freua 2021-12-23 22:57:21 -03:00
commit 5e7eac6be6
4 changed files with 43 additions and 16 deletions

View File

@ -1038,6 +1038,24 @@
"contributions": [ "contributions": [
"code" "code"
] ]
},
{
"login": "alirezaghey",
"name": "alirezaghey",
"avatar_url": "https://avatars.githubusercontent.com/u/26653424?v=4",
"profile": "https://github.com/alirezaghey",
"contributions": [
"content"
]
},
{
"login": "frvannes16",
"name": "Franklin van Nes",
"avatar_url": "https://avatars.githubusercontent.com/u/3188475?v=4",
"profile": "https://github.com/frvannes16",
"contributions": [
"code"
]
} }
], ],
"contributorsPerLine": 8, "contributorsPerLine": 8,

View File

@ -1,5 +1,5 @@
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-112-orange.svg?style=flat-square)](#contributors-) [![All Contributors](https://img.shields.io/badge/all_contributors-114-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END --> <!-- ALL-CONTRIBUTORS-BADGE:END -->
# rustlings 🦀❤️ # rustlings 🦀❤️
@ -317,6 +317,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="http://xuesong.pydevops.com"><img src="https://avatars.githubusercontent.com/u/18476085?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xuesong</b></sub></a><br /><a href="#content-xuesongbj" title="Content">🖋</a></td> <td align="center"><a href="http://xuesong.pydevops.com"><img src="https://avatars.githubusercontent.com/u/18476085?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xuesong</b></sub></a><br /><a href="#content-xuesongbj" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/MpdWalsh"><img src="https://avatars.githubusercontent.com/u/48160144?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michael Walsh</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=MpdWalsh" title="Code">💻</a></td> <td align="center"><a href="https://github.com/MpdWalsh"><img src="https://avatars.githubusercontent.com/u/48160144?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michael Walsh</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=MpdWalsh" title="Code">💻</a></td>
</tr> </tr>
<tr>
<td align="center"><a href="https://github.com/alirezaghey"><img src="https://avatars.githubusercontent.com/u/26653424?v=4?s=100" width="100px;" alt=""/><br /><sub><b>alirezaghey</b></sub></a><br /><a href="#content-alirezaghey" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/frvannes16"><img src="https://avatars.githubusercontent.com/u/3188475?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Franklin van Nes</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=frvannes16" title="Code">💻</a></td>
</tr>
</table> </table>
<!-- markdownlint-restore --> <!-- markdownlint-restore -->

View File

@ -8,10 +8,16 @@
// I AM NOT DONE // I AM NOT DONE
use std::f32;
fn main() { fn main() {
let x = 1.2331f64; let pi = 3.14f32;
let y = 1.2332f64; let radius = 5.00f32;
if y != x {
println!("Success!"); let area = pi * f32::powi(radius, 2);
}
println!(
"The area of a circle with radius {:.2} is {:.5}!",
radius, area
)
} }

View File

@ -114,8 +114,7 @@ path = "exercises/functions/functions5.rs"
mode = "compile" mode = "compile"
hint = """ hint = """
This is a really common error that can be fixed by removing one character. This is a really common error that can be fixed by removing one character.
It happens because Rust distinguishes between expressions and statements: expressions return It happens because Rust distinguishes between expressions and statements: expressions return a value based on their operand(s), and statements simply return a () type which behaves just like `void` in C/C++ language.
a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language.
We want to return a value of `i32` type from the `square` function, but it is returning a `()` type... We want to return a value of `i32` type from the `square` function, but it is returning a `()` type...
They are not the same. There are two solutions: They are not the same. There are two solutions:
1. Add a `return` ahead of `num * num;` 1. Add a `return` ahead of `num * num;`
@ -907,15 +906,15 @@ name = "clippy1"
path = "exercises/clippy/clippy1.rs" path = "exercises/clippy/clippy1.rs"
mode = "clippy" mode = "clippy"
hint = """ hint = """
Not every floating point value can be represented exactly in binary values in Rust stores the highest precision version of any long or inifinite precision
memory. Take a look at the description of mathematical constants in the rust standard library.
https://doc.rust-lang.org/stable/std/primitive.f32.html https://doc.rust-lang.org/stable/std/f32/consts/index.html
When using the binary compare operators with floating points you won't compare
the floating point values but the binary representation in memory. This is We may be tempted to use our own approximations for certain mathematical constants,
usually not what you would like to do. but clippy recognizes those imprecise mathematical constants as a source of
potential error.
See the suggestions of the clippy warning in compile output and use the See the suggestions of the clippy warning in compile output and use the
machine epsilon value... appropriate replacement constant from std::f32::consts..."""
https://doc.rust-lang.org/stable/std/primitive.f32.html#associatedconstant.EPSILON"""
[[exercises]] [[exercises]]
name = "clippy2" name = "clippy2"