Cargo Features
[dependencies]
thiserror = { version = "2.0.3", default-features = false, features = ["std"] }
- default = std
-
The
std
feature is set by default wheneverthiserror
is added without
somewhere in the dependency tree.default-features = false - std default
-
Std feature enables support for formatting std::path::{Path, PathBuf}
conveniently in an error message.
#[derive(Error, Debug)]
#[error("failed to create configuration file {path}")]
pub struct MyError {
pub path: PathBuf,
pub source: std::io::Error,
}
Without std, this would need to be written #[error("... {}", path.display())].