#Rust Reverse-Sting Help

9 messages · Page 1 of 1 (latest)

gleaming granite
#

Hi, im trying to complete the task above but I'm getting error[E0463]. I see that I may need to add the crate as one of the dependencies but i'm unsure as to how to do that... Could someone please help me? Thx in advance

#

Sorry that's meant to say String...

fringe slate
#

Could you share your code, the test code and test failure? Please use codeblocks. Please do not use screenshots.

gleaming granite
#

||extern crate unicode_segmentation;
use unicode_segmentation::UnicodeSegmentation;

pub fn reverse(input: &str) -> String {
todo!("Write a function to reverse {input}");

let input = input.to_string();
let output: String = x.graphemes(true).rev().collect();

}||

#

Is this ok?

#

|| Compiling reverse_string v1.2.0 (/Users/kenpandino/Exercism/rust/reverse-string)
error[E0463]: can't find crate for unicode_segmentation
--> src/lib.rs:1:1
|
1 | extern crate unicode_segmentation;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0425]: cannot find value x in this scope
--> src/lib.rs:8:26
|
8 | let output: String = x.graphemes(true).rev().collect();
| ^ not found in this scope

warning: unreachable statement
--> src/lib.rs:7:5
|
5 | todo!("Write a function to reverse {input}");
| -------------------------------------------- any code following this expression is unreachable
6 |
7 | let input = input.to_string();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
|
= note: #[warn(unreachable_code)] on by default

Some errors have detailed explanations: E0425, E0463.
For more information about an error, try rustc --explain E0425.
warning: reverse_string (lib test) generated 1 warning
error: could not compile reverse_string (lib test) due to 2 previous errors; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
warning: reverse_string (lib) generated 1 warning (1 duplicate)
error: could not compile reverse_string (lib) due to 2 previous errors; 1 warning emitted
||

#

and the error

faint solstice
#

The unicode_segmentation crate is only used if you enable the optional grapheme feature. The command to run the tests with this feature is in the exercise's instructions:

cargo test --features grapheme
dry ether