Skip to content

Rename smart_pointers and conversions exercises with numeric prefix#2391

Closed
foxfromworld wants to merge 1 commit intorust-lang:mainfrom
foxfromworld:issue-2023-rename-exercises
Closed

Rename smart_pointers and conversions exercises with numeric prefix#2391
foxfromworld wants to merge 1 commit intorust-lang:mainfrom
foxfromworld:issue-2023-rename-exercises

Conversation

@foxfromworld
Copy link
Copy Markdown

Following the maintainer’s guidance in issue #2023, applied Option B (numeric prefix + topic name) for exercises in smart_pointers and conversions.

Changes:

  • Renamed exercises and solutions with numeric prefixes (e.g., 1_box1, 2_rc1, etc.)
  • Updated rustlings-macros/info.toml accordingly
  • Adjusted dev/Cargo.toml to reflect new exercise names

Verification:

  • Ran cargo check
  • Ran cargo test
  • Ran cargo run --bin rustlings
  • Ran cargo run -- run 1_box1 → exercise loads and runs successfully
  • Ran cargo run -- run 2_rc1 → exercise loads and runs successfully
  • Ran cargo run -- run 3_arc1 → exercise loads and runs successfully
  • Ran cargo run -- run 4_cow1 → exercise loads and runs successfully
  • Ran cargo run -- run 1_using_as → exercise loads and runs successfully
  • Ran cargo run -- run 2_from_into → exercise loads and runs successfully
  • Ran cargo run -- run 3_from_str → exercise loads and runs successfully
  • Ran cargo run -- run 4_try_from_into → exercise loads and runs successfully
  • Ran cargo run -- run 5_as_ref_mut → exercise loads and runs successfully-

Screenshots and logs attached for reference.
image

image image
$ cargo run -- run 1_box1
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 1_box1`
error[E0072]: recursive type `List` has infinite size
  --> ../exercises/19_smart_pointers/1_box1.rs:14:1
   |
14 | enum List {
   | ^^^^^^^^^
15 |     Cons(i32, List),
   |               ---- recursive without indirection
   |
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
   |
15 |     Cons(i32, Box<List>),
   |               ++++    +

error[E0391]: cycle detected when computing drop-check constraints for `List`
  --> ../exercises/19_smart_pointers/1_box1.rs:14:1
   |
14 | enum List {
   | ^^^^^^^^^
   |
   = note: ...which immediately requires computing drop-check constraints for `List` again
   = note: cycle used when computing dropck types for `List`
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0391]: cycle detected when computing when `List` needs drop
  --> ../exercises/19_smart_pointers/1_box1.rs:14:1
   |
14 | enum List {
   | ^^^^^^^^^
   |
   = note: ...which immediately requires computing when `List` needs drop again
   = note: cycle used when computing whether `List` needs drop
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

Some errors have detailed explanations: E0072, E0391.
For more information about an error, try `rustc --explain E0072`.
error: could not compile `exercises` (bin "1_box1") due to 3 previous errors

Ran exercises/19_smart_pointers/1_box1.rs with errors
$ cargo run -- run 2_rc1
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 2_rc1`

running 1 test
test tests::rc1 ... FAILED

failures:

---- tests::rc1 stdout ----
reference count = 1
reference count = 2
Hi from Mercury(Sun)!
reference count = 3
Hi from Venus(Sun)!
reference count = 4
Hi from Earth(Sun)!
reference count = 5
Hi from Mars(Sun)!
reference count = 6
Hi from Jupiter(Sun)!
reference count = 6
Hi from Saturn(Sun)!
reference count = 6
Hi from Uranus(Sun)!
reference count = 6
Hi from Neptune(Sun)!

thread 'tests::rc1' (2895148) panicked at ../exercises/19_smart_pointers/2_rc1.rs:77:9:
assertion `left == right` failed
  left: 6
 right: 9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::rc1

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--bin 2_rc1`

Output

Ran exercises/19_smart_pointers/2_rc1.rs with errors
$ cargo run -- run 3_arc1
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 3_arc1`
error[E0425]: cannot find value `child_numbers` in this scope
  --> ../exercises/19_smart_pointers/3_arc1.rs:35:28
   |
35 | ...   let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
   |                      ^^^^^^^^^^^^^ not found in this scope

error: unused import: `sync::Arc`
  --> ../exercises/19_smart_pointers/3_arc1.rs:20:11
   |
20 | use std::{sync::Arc, thread};
   |           ^^^^^^^^^
   |
note: the lint level is defined here
  --> ../exercises/19_smart_pointers/3_arc1.rs:19:11
   |
19 | #![forbid(unused_imports)]
   |           ^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0425`.
error: could not compile `exercises` (bin "3_arc1") due to 2 previous errors

Ran exercises/19_smart_pointers/3_arc1.rs with errors
$ cargo run -- run 4_cow1
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 4_cow1`
error[E0532]: expected a pattern, found a function call
  --> ../exercises/19_smart_pointers/4_cow1.rs:42:33
   |
42 |         assert!(matches!(input, todo!()));
   |                                 ^^^^^^^ not a tuple struct or tuple variant
   |
   = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0532]: expected a pattern, found a function call
  --> ../exercises/19_smart_pointers/4_cow1.rs:55:33
   |
55 |         assert!(matches!(input, todo!()));
   |                                 ^^^^^^^ not a tuple struct or tuple variant
   |
   = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0532]: expected a pattern, found a function call
  --> ../exercises/19_smart_pointers/4_cow1.rs:67:33
   |
67 |         assert!(matches!(input, todo!()));
   |                                 ^^^^^^^ not a tuple struct or tuple variant
   |
   = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0532`.
error: could not compile `exercises` (bin "4_cow1" test) due to 3 previous errors

Output

Ran exercises/19_smart_pointers/4_cow1.rs with errors
$ cargo run -- run 1_using_as
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/rustlings run 1_using_as`
error[E0277]: cannot divide `f64` by `usize`
 --> ../exercises/23_conversions/1_using_as.rs:8:11
  |
8 |     total / values.len()
  |           ^ no implementation for `f64 / usize`
  |
  = help: the trait `Div<usize>` is not implemented for `f64`
help: the following other types implement trait `Div<Rhs>`
 --> /rustc/254b59607d4417e9dffbc307138ae5c86280fe4c/library/core/src/ops/arith.rs:526:1
  |
  = note: `&f64` implements `Div<f64>`
  |
  = note: `&f64` implements `Div`
  |
  = note: `f64` implements `Div<&f64>`
  |
  = note: `f64` implements `Div`
  = note: this error originates in the macro `div_impl_float` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `exercises` (bin "1_using_as") due to 1 previous error

Ran exercises/23_conversions/1_using_as.rs with errors
$ cargo run -- run 2_from_into
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/rustlings run 2_from_into`
error[E0308]: mismatched types
  --> ../exercises/23_conversions/2_from_into.rs:37:25
   |
37 |     fn from(s: &str) -> Self {}
   |        ----             ^^^^ expected `Person`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression

For more information about this error, try `rustc --explain E0308`.
error: could not compile `exercises` (bin "2_from_into") due to 1 previous error

Ran exercises/23_conversions/2_from_into.rs with errors
$ cargo run -- run 3_from_str
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 3_from_str`
error[E0308]: mismatched types
  --> ../exercises/23_conversions/3_from_str.rs:44:29
   |
44 |     fn from_str(s: &str) -> Result<Self, Self::Err> {}
   |        --------             ^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<Person, ParsePersonError>`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<Person, ParsePersonError>`
           found unit type `()`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `exercises` (bin "3_from_str") due to 1 previous error

Ran exercises/23_conversions/3_from_str.rs with errors
$ cargo run -- run 4_try_from_into
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 4_try_from_into`
error[E0308]: mismatched types
  --> ../exercises/23_conversions/4_try_from_into.rs:31:44
   |
31 |     fn try_from(tuple: (i16, i16, i16)) -> Result<Self, Self::Error> {}
   |        --------                            ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<Color, IntoColorError>`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<Color, IntoColorError>`
           found unit type `()`

error[E0308]: mismatched types
  --> ../exercises/23_conversions/4_try_from_into.rs:38:35
   |
38 |     fn try_from(arr: [i16; 3]) -> Result<Self, Self::Error> {}
   |        --------                   ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<Color, IntoColorError>`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<Color, IntoColorError>`
           found unit type `()`

error[E0308]: mismatched types
  --> ../exercises/23_conversions/4_try_from_into.rs:46:35
   |
46 |     fn try_from(slice: &[i16]) -> Result<Self, Self::Error> {}
   |        --------                   ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<Color, IntoColorError>`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<Color, IntoColorError>`
           found unit type `()`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `exercises` (bin "4_try_from_into") due to 3 previous errors

Ran exercises/23_conversions/4_try_from_into.rs with errors
$ cargo run -- run 5_as_ref_mut
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/rustlings run 5_as_ref_mut`
error[E0599]: no method named `as_ref` found for type parameter `T` in the current scope
 --> ../exercises/23_conversions/5_as_ref_mut.rs:9:9
  |
8 | fn byte_counter<T>(arg: T) -> usize {
  |                 - method `as_ref` not found for this type parameter
9 |     arg.as_ref().len()
  |         ^^^^^^ method not found in `T`
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `as_ref`, perhaps you need to restrict type parameter `T` with it:
  |
8 | fn byte_counter<T: AsRef</* T */>>(arg: T) -> usize {
  |                  ++++++++++++++++

error[E0599]: no method named `as_ref` found for type parameter `T` in the current scope
  --> ../exercises/23_conversions/5_as_ref_mut.rs:15:9
   |
14 | fn char_counter<T>(arg: T) -> usize {
   |                 - method `as_ref` not found for this type parameter
15 |     arg.as_ref().chars().count()
   |         ^^^^^^ method not found in `T`
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `as_ref`, perhaps you need to restrict type parameter `T` with it:
   |
14 | fn char_counter<T: AsRef</* T */>>(arg: T) -> usize {
   |                  ++++++++++++++++

warning: unused variable: `arg`
  --> ../exercises/23_conversions/5_as_ref_mut.rs:20:14
   |
20 | fn num_sq<T>(arg: &mut T) {
   |              ^^^ help: if this is intentional, prefix it with an underscore: `_arg`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

For more information about this error, try `rustc --explain E0599`.
error: could not compile `exercises` (bin "5_as_ref_mut") due to 2 previous errors; 1 warning emitted

Ran exercises/23_conversions/5_as_ref_mut.rs with errors

Update rustlings-macros/info.toml and dev/Cargo.toml accordingly
@senekor
Copy link
Copy Markdown
Contributor

senekor commented May 5, 2026

Just to clarify, I'm not an official maintainer. This approach still needs an OK from Mo.

@mo8it
Copy link
Copy Markdown
Contributor

mo8it commented May 5, 2026

You can already see in the screenshot that this is not consistent with other sections like traits and macros. We should go with the other option to stay consistent.

@mo8it mo8it closed this May 5, 2026
@foxfromworld
Copy link
Copy Markdown
Author

You can already see in the screenshot that this is not consistent with other sections like traits and macros. We should go with the other option to stay consistent.

Understood, thanks for clarifying. I’ll follow the existing convention (Option A) in future contributions.

For reference, here’s how I plan to rename the files to align with the convention:

19_smart_pointers
box1.rs  -> smart_pointers1.rs
rc1.rs   -> smart_pointers2.rs
arc1.rs  -> smart_pointers3.rs
cow1.rs  -> smart_pointers4.rs

23_conversions
using_as.rs      -> conversions1.rs
from_into.rs     -> conversions2.rs
from_str.rs      -> conversions3.rs
try_from_into.rs -> conversions4.rs
as_ref_mut.rs    -> conversions5.rs

@mo8it
Copy link
Copy Markdown
Contributor

mo8it commented May 5, 2026

Yes, I would merge that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants