Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust errors #3

Open
xgqfrms opened this issue Sep 5, 2022 · 4 comments
Open

rust errors #3

xgqfrms opened this issue Sep 5, 2022 · 4 comments
Labels
bug Something isn't working Cargo Cargo good first issue Good for newcomers Rust Playground Rust Playground Rust plugin/crate Rust plugin/crate

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented Sep 5, 2022

rust errors

image

crate 箱

$ rustc app.rs
error[E0463]: can't find crate for `ferris_says`
 --> app.rs:2:1
  |
2 | extern crate ferris_says;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

rustc --explain E0463

A plugin/crate was declared but cannot be found.

You need to link your code to the relevant crate in order to be able to use it (through Cargo or the -L option of rustc example).

Plugins are crates as well, and you link to them the same way.

A plugin/crate was declared but cannot be found.

Erroneous code example:

\`\`\`
#![feature(plugin)]
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
\`\`\`

You need to link your code to the relevant crate in order to be able to use it (through Cargo or the `-L` option of rustc example). 
Plugins are crates as well, and you link to them the same way.

## Common causes

## Common causes

- The crate is not present at all. If using Cargo, add it to `[dependencies]` in Cargo.toml.
- The crate is present, but under a different name. If using Cargo, look for `package = ` under `[dependencies]` in Cargo.toml.

## Common causes for missing `std` or `core`

- You are cross-compiling for a target which doesn't have `std` prepackaged.
  Consider one of the following:
  + Adding a pre-compiled version of std with `rustup target add`
  + Building std from source with `cargo build -Z build-std`
  + Using `#![no_std]` at the crate root, so you won't need `std` in the first place.
- You are developing the compiler itself and haven't built libstd from source.
  You can usually build it with `x.py build library/std`. More information about x.py is available in the [rustc-dev-guide].

[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler

https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler

@xgqfrms
Copy link
Owner Author

xgqfrms commented Sep 5, 2022

@xgqfrms xgqfrms added Cargo Cargo bug Something isn't working Rust plugin/crate Rust plugin/crate good first issue Good for newcomers Rust Playground Rust Playground labels Sep 5, 2022
@xgqfrms
Copy link
Owner Author

xgqfrms commented Sep 5, 2022

ferris-says v0.2.1

A Rust flavored replacement for the classic cowsay

https://crates.io/search?q=ferris_says

https://crates.io/crates/ferris-says

Cargo.toml

[dependencies]
ferris-says = "0.2"

image

https://github.com/mgattozzi/ferris-says

ferris-says = "0.2.1"

https://github.com/mgattozzi/ferris-says/blob/master/fsays/Cargo.toml#L22

https://github.com/mgattozzi/ferris-says/blob/master/Cargo.toml#L1

https://github.com/mgattozzi/ferris-says/blob/master/src/lib.rs#L12

#[cfg(not(feature = "clippy"))]
const FERRIS: &[u8] = br#"
        \
         \
            _~^~^~_
        \) /  o o  \ (/
          '_   -   _'
          / '-----' \
"#;

#[cfg(feature = "clippy")]
const CLIPPY: &[u8] = br#"
        \
         \
            __
           /  \
           |  |
           @  @
           |  |
           || |/
           || ||
           |\_/|
           \___/
"#;

cowsay

https://crates.io/search?q=cowsay

cowsay is a program that generates ASCII art pictures of a cow with a message.

cowsay 是一个程序,它可以生成带有信息的奶牛的 ASCII 艺术图片。

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented Sep 5, 2022

println 插值

https://doc.rust-lang.org/std/macro.println.html

https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Aprintln!()%3B%20%2F%2F%20prints%20just%20a%20newline%0Aprintln!(%22hello%20there!%22)%3B%0Aprintln!(%22format%20%7B%7D%20arguments%22%2C%20%22some%22)%3B%0A%7D&edition=2021

image

fn main() {
    println!("🦀 Hello, world!");
    println!("\n$ rustc -V");
    println!("rustc 1.63.0 (4b91a6ea7 2022-08-08)");
    // 调用 function
    add(1, 2);
}

// fn 定义 function
fn add(left: usize, right: usize) -> usize {
  // {} 插值,占位符
  println!("\n🦀 left = {}, right = {}", left, right);
  println!("🦀🦀 left + right = {}", left + right);
  println!("\n🦀🦀🦀 left = {}, right = {}, left + right = {}", left, right, left + right);
  left + right
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Cargo Cargo good first issue Good for newcomers Rust Playground Rust Playground Rust plugin/crate Rust plugin/crate
Projects
None yet
Development

No branches or pull requests

1 participant