Consider renaming "unwrap" methods to "get", and rename "expect" to something better
Methods such as unwrap, unwrap_or, unwrap_or_else aren't very descriptive if you've not used Rust before, as it's not clear what "unwrapping" means.
Similarly, expect is poorly named and pushes users in the direction of writing error messages that say what should've happened rather than what happened, with the problem being that it's sometimes really difficult to write such error messages.
I'm now thinking of renaming such methods as follows:
-
unwrapbecomesget -
unwrap_orbecomesor -
unwrap_or_elsebecomesor_else -
expectbecomesor_panic,or_fail, or something along those lines; not sure yet
Another issue with expect is that even if the thrown error value can be formatted, expect ignores it so you lose information about the error. To handle that we'd probably need a separate method implemented along the lines of the following:
impl Result if E: ToString {
fn pub require -> T {
match self {
case Ok(v) -> v
case Error(e) -> panic(e.to_string)
}
}
}
This however results in an inconsistency between users using require and whatever we rename expect to, which can be annoying.