0
我是新來的鏽和我試圖打開一個窗口與Conrod library,就像他們在canvas.rs
example那樣:不能在我的鏽項目中使用的連桿庫:找不到箱子piston_window
#[macro_use] extern crate conrod;
extern crate find_folder;
extern crate piston_window;
use conrod::{Canvas, Theme, Widget, color};
use piston_window::{EventLoop, OpenGL, PistonWindow, UpdateEvent, WindowSettings};
fn main() {
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
// Change this to OpenGL::V2_1 if not working.
let opengl = OpenGL::V3_2;
// Construct the window.
let mut window: PistonWindow =
WindowSettings::new("Canvas Demo", [WIDTH, HEIGHT].opengl(opengl).exit_on_esc(true).vsync(true).build().unwrap();
window.set_ups(60);
}
此代碼的工作,當我在連桿項目(一個我從GitHub下載)AA文件中使用它,但是當我在我自己的代碼中使用它,它不工作:
extern crate conrod;
extern crate piston_window;
fn main() {
println!("Hello, world!");
}
隨着以下Cargo.toml:
[package]
name = "hello_conrod"
version = "0.1.0"
authors = ["omega"]
[dependencies]
conrod = "0.37.2"
那麼編譯器告訴我:
error: can't find crate for `piston_window` [E0463]
我想我Cargo.toml
是錯誤的,但我沒有一個線索我應該做的。
在過去,我試圖通過將pinston_window =「*」添加到我的cargo.toml來添加箱子piston_window,但它沒有工作,但我仍然試着你剛剛告訴我的,代碼正在編譯.. –
它正在工作TY,但我不明白,是不是假設工作我有piston_window =「*」在湯姆?我想如何知道我添加的最後一個版本的依賴性? –
當你在crates.io上搜索一個包時,有一個框需要複製,例如在[lazy_static](https://crates.io/crates/lazy_static)頁面上,你可以看到' lazy_static =「0.2.1」'。別擔心 - 沒有人希望你學習並記住版本,但使用「*」是不好的做法,因爲這意味着你的代碼將來可能會崩潰。 – Aurora0001