diff --git a/.all-contributorsrc b/.all-contributorsrc index cda03778..f04a0ce2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1038,6 +1038,24 @@ "contributions": [ "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, diff --git a/README.md b/README.md index c0ba6ce9..469e1ef0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![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-) # rustlings 🦀❤️ @@ -317,6 +317,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
xuesong

🖋
Michael Walsh

💻 + +
alirezaghey

🖋 +
Franklin van Nes

💻 + diff --git a/exercises/clippy/clippy1.rs b/exercises/clippy/clippy1.rs index bdb5dd2c..c5f84a9c 100644 --- a/exercises/clippy/clippy1.rs +++ b/exercises/clippy/clippy1.rs @@ -8,10 +8,16 @@ // I AM NOT DONE +use std::f32; + fn main() { - let x = 1.2331f64; - let y = 1.2332f64; - if y != x { - println!("Success!"); - } + let pi = 3.14f32; + let radius = 5.00f32; + + let area = pi * f32::powi(radius, 2); + + println!( + "The area of a circle with radius {:.2} is {:.5}!", + radius, area + ) } diff --git a/info.toml b/info.toml index 5eece6d7..0c03def3 100644 --- a/info.toml +++ b/info.toml @@ -114,8 +114,7 @@ path = "exercises/functions/functions5.rs" mode = "compile" hint = """ 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 -a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language. +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. 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: 1. Add a `return` ahead of `num * num;` @@ -907,15 +906,15 @@ name = "clippy1" path = "exercises/clippy/clippy1.rs" mode = "clippy" hint = """ -Not every floating point value can be represented exactly in binary values in -memory. Take a look at the description of -https://doc.rust-lang.org/stable/std/primitive.f32.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 -usually not what you would like to do. +Rust stores the highest precision version of any long or inifinite precision +mathematical constants in the rust standard library. +https://doc.rust-lang.org/stable/std/f32/consts/index.html + +We may be tempted to use our own approximations for certain mathematical constants, +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 -machine epsilon value... -https://doc.rust-lang.org/stable/std/primitive.f32.html#associatedconstant.EPSILON""" +appropriate replacement constant from std::f32::consts...""" [[exercises]] name = "clippy2"