You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the referred pages, the example code below the title A small Rust application DOESN'T compile.
error[E0308]: mismatched types
--> src/main.rs:10:9
|
10 | say(message.as_bytes(), width, &mut writer).unwrap();
| --- ^^^^^^^^^^^^^^^^^^ expected `&str`, found `&[u8]`
| |
| arguments to this function are incorrect
|
= note: expected reference `&str`
found reference `&[u8]`
note: function defined here
--> /Users/username/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ferris-says-0.3.1/src/lib.rs:84:8
|
84 | pub fn say<W>(input: &str, max_width: usize, mut writer: W) -> Result<()>
| ^^^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `rust-journey` (bin "rust-journey") due to previous error
Suggested Improvement
Fix the code with the following:
use ferris_says::say;// from the previous stepuse std::io::{stdout,BufWriter};fnmain(){let stdout = stdout();let message = String::from("Hello fellow Rustaceans!");let width = message.chars().count();letmut writer = BufWriter::new(stdout.lock());say(&message, width,&mut writer).unwrap();// Change only this line}
The text was updated successfully, but these errors were encountered:
Page(s) Affected
https://www.rust-lang.org/learn/get-started
https://www.rust-lang.org/zh-CN/learn/get-started
https://www.rust-lang.org/zh-TW/learn/get-started
etc. (in other languages)
What needs to be fixed?
In the referred pages, the example code below the title A small Rust application DOESN'T compile.
Suggested Improvement
Fix the code with the following:
The text was updated successfully, but these errors were encountered: