use std::io; 없이 사용시
error[E0433]: failed to resolve: use of undeclared crate or module `io` --> main.rs:8:5 | 8 | io::stdin() | ^^ | | | use of undeclared crate or module `io` | help: a builtin type with a similar name exists: `i8` error: aborting due to previous error For more information about this error, try `rustc --explain E0433`. |
변수 사용 없음 (경고)
warning: unused `Result` that must be used --> main.rs:10:5 | 10 | / io::stdin() 11 | | .read_line(&mut guess); | |______________________________^ | = note: this `Result` may be an `Err` variant, which should be handled = note: `#[warn(unused_must_use)]` on by default warning: 1 warning emitted |
read_line mut 없이
error[E0308]: mismatched types --> main.rs:11:20 | 11 | .read_line(&guess); | --------- ^^^^^^ types differ in mutability | | | arguments to this method are incorrect | = note: expected mutable reference `&mut String` found reference `&String` note: method defined here --> /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\library\std\src\io\stdio.rs:383:12 error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. |
///
let guess = String::new();
io::stdin().read_line(&mut guess);
///
error[E0596]: cannot borrow `guess` as mutable, as it is not declared as mutable --> main.rs:11:20 | 11 | .read_line(&mut guess); | ^^^^^^^^^^ cannot borrow as mutable | help: consider changing this to be mutable | 8 | let mut guess = String::new(); | +++ error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. |
//
let guess = String::new();
io::stdin().read_line(&guess);
//
error[E0308]: mismatched types --> main.rs:9:27 | 9 | io::stdin().read_line(&guess); | --------- ^^^^^^ types differ in mutability | | | arguments to this method are incorrect | = note: expected mutable reference `&mut String` found reference `&String` note: method defined here --> /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\library\std\src\io\stdio.rs:383:12 error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. |
'Programming > rust' 카테고리의 다른 글
rust mut (0) | 2023.05.25 |
---|---|
rust visibility and privacy (0) | 2023.05.25 |
rust 소유권 (0) | 2023.05.25 |
rust was (0) | 2023.05.20 |
c에서 rust 호출하기 (0) | 2023.05.11 |