如何使 Rust 草书的示例在 Windows 上运行?

问题描述

Rust cursive一个 Rust TUI 框架。 states that 您可以切换后端,其中一些是 Windows 支持的。但是,我无法让它发挥作用。当我运行以下命令(从 here 获取)时,出现错误

$ git clone https://github.com/gyscos/cursive
$ cd cursive/examples

$ cargo run -v --no-default-features --features pancurses-backend --example select
error: Package `cursive-examples v0.1.1-alpha.0 (C:\my_projects\cursive\examples)`
does not have the feature `pancurses-backend`

在 Windows 上运行这些示例的正确方法是什么?

解决方法

正如错误所说,examples package 没有 pancurses-backend 功能,如果您查看 examples/Cargo.toml 是正确的。 pancurses-backend 功能实际上位于 cursiveCargo.toml 中。

因此要启用它,您必须改为执行 --features cursive/pancurses-backend

虽然该目录有点误导被称为examples。在这种情况下,您不能使用 --example,因为它们不是 Cargo 意义上的示例。相反,您需要使用 --bin

cargo run -v --no-default-features --features cursive/pancurses-backend --bin select
,

设置

[dependencies.cursive] 
version = "0.16.3"
default-features = false
features = ["crossterm-backend"]

在 Cargo.toml 中也适用于我在 Windows 上

然后简单地开火

cargo run