summaryrefslogtreecommitdiff
path: root/exercises/23_conversions
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-17 23:34:27 +0200
committermo8it <mo8it@proton.me>2024-04-17 23:34:27 +0200
commit2f810a4da67233716ad93e00afff6e8b260f4807 (patch)
treef5a33357141d25d08b6726910efe33f2338b9cdb /exercises/23_conversions
parentcb9f1ac9ce3c834b0cca964b6809b74508f80b54 (diff)
Clean up and unify exercises
Diffstat (limited to 'exercises/23_conversions')
-rw-r--r--exercises/23_conversions/as_ref_mut.rs5
-rw-r--r--exercises/23_conversions/from_into.rs6
-rw-r--r--exercises/23_conversions/from_str.rs5
-rw-r--r--exercises/23_conversions/try_from_into.rs5
-rw-r--r--exercises/23_conversions/using_as.rs5
5 files changed, 0 insertions, 26 deletions
diff --git a/exercises/23_conversions/as_ref_mut.rs b/exercises/23_conversions/as_ref_mut.rs
index 6fb7c2f..c725dfd 100644
--- a/exercises/23_conversions/as_ref_mut.rs
+++ b/exercises/23_conversions/as_ref_mut.rs
@@ -1,11 +1,6 @@
-// as_ref_mut.rs
-//
// AsRef and AsMut allow for cheap reference-to-reference conversions. Read more
// about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html and
// https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
-//
-// Execute `rustlings hint as_ref_mut` or use the `hint` watch subcommand for a
-// hint.
// Obtain the number of bytes (not characters) in the given argument.
// TODO: Add the AsRef trait appropriately as a trait bound.
diff --git a/exercises/23_conversions/from_into.rs b/exercises/23_conversions/from_into.rs
index d2a1609..9df10da 100644
--- a/exercises/23_conversions/from_into.rs
+++ b/exercises/23_conversions/from_into.rs
@@ -1,11 +1,6 @@
-// from_into.rs
-//
// The From trait is used for value-to-value conversions. If From is implemented
// correctly for a type, the Into trait should work conversely. You can read
// more about it at https://doc.rust-lang.org/std/convert/trait.From.html
-//
-// Execute `rustlings hint from_into` or use the `hint` watch subcommand for a
-// hint.
#[derive(Debug)]
struct Person {
@@ -24,7 +19,6 @@ impl Default for Person {
}
}
-
// Your task is to complete this implementation in order for the line `let p1 =
// Person::from("Mark,20")` to compile. Please note that you'll need to parse the
// age component into a `usize` with something like `"4".parse::<usize>()`. The
diff --git a/exercises/23_conversions/from_str.rs b/exercises/23_conversions/from_str.rs
index ed91ca5..58270f0 100644
--- a/exercises/23_conversions/from_str.rs
+++ b/exercises/23_conversions/from_str.rs
@@ -1,13 +1,8 @@
-// from_str.rs
-//
// This is similar to from_into.rs, but this time we'll implement `FromStr` and
// return errors instead of falling back to a default value. Additionally, upon
// implementing FromStr, you can use the `parse` method on strings to generate
// an object of the implementor type. You can read more about it at
// https://doc.rust-lang.org/std/str/trait.FromStr.html
-//
-// Execute `rustlings hint from_str` or use the `hint` watch subcommand for a
-// hint.
use std::num::ParseIntError;
use std::str::FromStr;
diff --git a/exercises/23_conversions/try_from_into.rs b/exercises/23_conversions/try_from_into.rs
index 2316655..da45e5a 100644
--- a/exercises/23_conversions/try_from_into.rs
+++ b/exercises/23_conversions/try_from_into.rs
@@ -1,13 +1,8 @@
-// try_from_into.rs
-//
// TryFrom is a simple and safe type conversion that may fail in a controlled
// way under some circumstances. Basically, this is the same as From. The main
// difference is that this should return a Result type instead of the target
// type itself. You can read more about it at
// https://doc.rust-lang.org/std/convert/trait.TryFrom.html
-//
-// Execute `rustlings hint try_from_into` or use the `hint` watch subcommand for
-// a hint.
use std::convert::{TryFrom, TryInto};
diff --git a/exercises/23_conversions/using_as.rs b/exercises/23_conversions/using_as.rs
index 9f617ec..94b1bb3 100644
--- a/exercises/23_conversions/using_as.rs
+++ b/exercises/23_conversions/using_as.rs
@@ -1,14 +1,9 @@
-// using_as.rs
-//
// Type casting in Rust is done via the usage of the `as` operator. Please note
// that the `as` operator is not only used when type casting. It also helps with
// renaming imports.
//
// The goal is to make sure that the division does not fail to compile and
// returns the proper type.
-//
-// Execute `rustlings hint using_as` or use the `hint` watch subcommand for a
-// hint.
fn average(values: &[f64]) -> f64 {
let total = values.iter().sum::<f64>();