I’m a Rust newbie. It’s therefore EXTREMELY frustrating that this exercise says “go ahead and use an external crate” only for the test system to shrug and say “external crates? What are they?!”. (Submitting the Cargo.lock file doesn’t fix it, either.)
After digging, I found that that’s a design decision to avoid abuse, which is fair enough. But to have the second exercise bug out because of it, with no warning or information about it in the lesson, is dreadful. I’m old enough and ugly enough to figure it out, but I would imagine that newer devs would be completely put off by this and give up.
I think this needs to have a warning in the text saying “hey! if you do this, it won’t pass the tests”, or to have the extension removed. It’s a really poor show otherwise.
I appreciate everyone’s a volunteer, and I don’t mean to sound prickly – however, it’s hard to overstate the importance of the early exercises working smoothly if you want people to progress.
error: no matching package named `unicode-reverse` found
location searched: registry `crates-io`
required by package `reverse_string v1.2.0 (exercism-iteration)`
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.
But I’m not asking for help with the error. I’m saying that I’ve followed the exercise instructions, submitted code that passes locally, and the editor fails it because of a design decision.
This is the second exercise. If there are footguns around, they ought to be explicitly called out ahead of time. A new dev isn’t going to go rummaging around in the forums looking for solutions, they’re going to give up.
Yeah, imrpoving the instructions is an easy fix. That and possibly improve the error message from the test runner for the general case when someone uses an unsupported crate.
You can also use the DSA method Two-Pointer to traverse through the array, and then use it’s target to determine the reverse string by copying it into a new array.
Such as this:
int left = 0;
int right = array.Length-1;
for(int i = 0; i < array.Length; i++)
{
//Logic here
left++;}
while(Condition is broken)
{
//logic here
}
right–;
Apologies if this is not in rust, but you get the idea?
Your list mentions unicode-segmentation and counter, however using them in my solution gives me the error below. How can I avoid this?
Compiling anagram v0.0.0 (exercism-iteration)
error[E0432]: unresolved import `unicode_segmentation`
--> src/lib.rs:2:5
|
2 | use unicode_segmentation;
| ^^^^^^^^^^^^^^^^^^^^ no external crate `unicode_segmentation`
error[E0432]: unresolved import `counter`
--> src/lib.rs:4:5
|
4 | use counter::Counter;
| ^^^^^^^ use of undeclared crate or module `counter`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `anagram` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `anagram` due to 2 previous errors
How did you submit your solution? Did you submit Cargo.toml as well? You can check the state of each file in exercism’s UI directly when you look at your submission, I think.
If you submitted with
exercism submit
It should submit Cargo.toml correctly. I think Cargo.toml will be excluded if you do it like this:
The online editor has tabs for all the project files. Usually you only edit src/lib.rs. If you want to add dependencies, go to the Cargo.toml tab and add them to the [dependencies] section.
It can be bothersome to look up / copy-paste the latest version of a crate, the wildcard syntax comes in handy: