From 8ef4869b264094e5a9b50452b4534823a9df19c3 Mon Sep 17 00:00:00 2001 From: alirezaghey Date: Wed, 15 Dec 2021 10:44:21 +0100 Subject: [PATCH 1/6] fix(functions5): Remove wrong new line and small English improvements (#885) --- info.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/info.toml b/info.toml index 5eece6d7..95850c63 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;` From 72b2c9f54f5f4d246616af767a1a842223702a13 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:44:38 +0000 Subject: [PATCH 2/6] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0ba6ce9..7595a9eb 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-113-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -317,6 +317,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
xuesong

🖋
Michael Walsh

💻 + +
alirezaghey

🖋 + From 527a5b1182483aa467556c1a36d9322440befa43 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:44:39 +0000 Subject: [PATCH 3/6] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index cda03778..6bf3853e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1038,6 +1038,15 @@ "contributions": [ "code" ] + }, + { + "login": "alirezaghey", + "name": "alirezaghey", + "avatar_url": "https://avatars.githubusercontent.com/u/26653424?v=4", + "profile": "https://github.com/alirezaghey", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From f2650de369810867d2763e935ac0963c32ec420e Mon Sep 17 00:00:00 2001 From: Franklin van Nes Date: Wed, 15 Dec 2021 11:46:27 -0500 Subject: [PATCH 4/6] fix(clippy1): Updated code to test correctness clippy lint with approx_constant lint rule closes #888 --- exercises/clippy/clippy1.rs | 16 +++++++++++----- info.toml | 16 ++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) 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 95850c63..0c03def3 100644 --- a/info.toml +++ b/info.toml @@ -906,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" From 8d675198d81eedb02ef3124321670000f0f6fd6c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 16 Dec 2021 13:11:14 +0000 Subject: [PATCH 5/6] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7595a9eb..469e1ef0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-113-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-114-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -319,6 +319,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
alirezaghey

🖋 +
Franklin van Nes

💻 From 81fb3967805a939f1149f0451afd94d566ab4d2a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 16 Dec 2021 13:11:15 +0000 Subject: [PATCH 6/6] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6bf3853e..f04a0ce2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1047,6 +1047,15 @@ "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,