Wątek przeniesiony 2021-08-05 11:50 z Inne języki programowania przez cerrato.

Rust error przy dodawaniu pakietów

0

Mam taki kod w Rust.

use ferris_says::say; // from the previous step
//use extern crate ferris_says;
use std::io::{stdout, BufWriter};

pub fn run() {
    let stdout = stdout();
    let out = b"Hello fellow Rustaceans!";
    let width = 24;

    let mut writer = BufWriter::new(stdout.lock());
    say(out, width, &mut writer).unwrap();
}

Tak wygląda main


mod hello_fellow;

fn main() {
    
    hello_fellow::run();
}


A tak błąd

cargo run
   Compiling dcode v0.1.0 (/home/user/Rust/dcode)
error[E0432]: unresolved import `ferris_says`
 --> src/hello_fellow.rs:1:5
  |
1 | use ferris_says::say; // from the previous step
  |     ^^^^^^^^^^^ use of undeclared type or module `ferris_
says`

error: aborting due to previous error

For more information about this error, try `rustc --explain E
0432`.
error: Could not compile `dcode`.
To learn more, run the command again with --verbose.
1

Pokaż swój plik Cargo.toml

0
[package]
name = "dcode"
version = "0.1.0"
authors = ["user"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

Niby tam dodałem ferris-says = "0.1" oraz extern crate ferris_says; ale wyskakuje znowu to:
cargo run
Blocking waiting for file lock on package cache

1
  1. extern crate ferris_says; to relikt przeszłości, który nie jest już wymagany.

  2. Blocking waiting for file lock on package cache oznacza, że jedna instancja Cargo działa aktualnie w tle (np. jeśli korzystasz z dodatku IntelliJ Rust, po każdej edycji Cargo.toml IDE automatycznie odpala Cargo w celu pobrania kodów źródłowych). Poczekaj chwilę i uruchom ponownie.

1 użytkowników online, w tym zalogowanych: 0, gości: 1