Reversing strings, external crates

Hello,

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.

Hi, thanks for the report. What’s the error message you’re getting? A predefined list of external crates is supported. Here’s the list:

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.

+1. If the exercise explicitly encourages the use of external crates, a link to which external crates are allowed would be nice.

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.

PRs:

2 Likes

These are all great. Thanks @senekor.

1 Like

:partying_face:

Interestingly, this is detected and highlighted as the language Red ? :smile:

3 Likes

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?