【文件属性】:
文件名称:simple-error:提供简单错误的Rust库
文件大小:11KB
文件格式:ZIP
更新时间:2021-05-28 04:24:52
error Rust
简单错误
simple-error是一个Rust库,提供了一个由String支持的简单Error类型。 当您只关心错误字符串时,最好使用该字符串。
用法
要使用simple-error ,首先将其添加到您的Cargo.toml :
[ dependencies ]
simple-error = " 0.2 "
然后将其添加到您的板条箱根目录:
#[macro_use]
extern crate simple_error;
use simple_error :: SimpleError;
或者,如果您使用的是2018版或更高版本,则可以跳过extern crate而仅导入您使用的相关项目。
现在,您可以通过不同的方式使用simple-error :
您可以简单地将其用作字符串错误类型:
fn do_foo () -> Result <(), SimpleError> {
【文件预览】:
simple-error-master
----LICENSE-MIT(1KB)
----LICENSE-APACHE(11KB)
----.github()
--------workflows()
----src()
--------lib.rs(13KB)
----Cargo.toml(365B)
----LICENSE.md(495B)
----.gitignore(18B)
----CHANGELOG.md(1KB)
----README.md(2KB)