-
Notifications
You must be signed in to change notification settings - Fork 31
Add trait for ergonomic Options-as-Errors #25
base: master
Are you sure you want to change the base?
Conversation
Not sure if this
|
7187dd4
to
728be3b
Compare
I think the docs could clarify a bit more what this is useful since I am still confused. Is the use of this to eliminate having to do:
and instead do:
In that case maybe |
Also I just realized something... |
Rust already has support for using let v = json!({ "a": 64, "b": big, "c": 256.0 });
// ...
let a = v["a"].as_i64().none_means("a field wasn't an integer")?; Thinking about it, it's very similar to
It's not really |
Why not call this feature So match maybe {
Some(v) => Ok(v),
None => Err("error msg"),
} would be rewritten as: maybe.ok_or_err("error msg") |
Yeah, I kinda wanted to go with a not-similar name because I don't want user to need to think about that this maps an Option to a Result. I want you to use to slap |
I'm not found of that, that's just about the same as maybe.ok_or("error msg")? |
No description provided.