#Rust Reverse-Sting Help
9 messages · Page 1 of 1 (latest)
Could you share your code, the test code and test failure? Please use codeblocks. Please do not use screenshots.
||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
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
The crate still won't be automatically added - edit Cargo.toml to add it as a dependency https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html