pub trait StringResultExt<T> {
// Required method
fn with_context(self, context: &str) -> Result<T, String>;
}Expand description
Extension trait that adds .with_context() to Result<T, String>.
Many stdlib module functions return Result<T, String>. This trait
lets callers wrap a bare string error with function-name context:
ⓘ
serde_json::from_str(data)
.map_err(|e| e.to_string())
.with_context("json.parse")?;
// error becomes: "json.parse(): <original message>"Required Methods§
Sourcefn with_context(self, context: &str) -> Result<T, String>
fn with_context(self, context: &str) -> Result<T, String>
Wrap the error string with "context(): original_error" on failure.