Skip to content

Commit f12d129

Browse files
committed
Major convert refactor. Add new UniResultContext methods and many renames.
1 parent f82ea7e commit f12d129

File tree

8 files changed

+179
-124
lines changed

8 files changed

+179
-124
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use uni_error::*;
6666

6767
fn do_something() -> SimpleResult<Vec<u8>> {
6868
std::fs::read("/tmp/nonexist")
69-
.context("Oops... I wanted this to work!")
69+
.kind_default_context("Oops... I wanted this to work!")
7070
}
7171

7272
fn main() {
@@ -86,7 +86,7 @@ fn do_something() -> Result<(), String> {
8686
}
8787

8888
fn try_do_something() -> SimpleResult<()> {
89-
do_something().context_disp("Oops... I wanted this to work!")
89+
do_something().kind_default_context_disp("Oops... I wanted this to work!")
9090
}
9191

9292
fn main() {
@@ -138,22 +138,29 @@ If the error type implements `std::error::Error`, or is `UniError<T>` --> `UniEr
138138
result?
139139
```
140140

141-
`UniError<T>` --> `UniError<U>` (`U` must implement `Default`):
141+
`UniError<T>` --> `UniError<U>` (`U` implements `Default`):
142142

143143
```text
144-
result.wrap()?
144+
result.kind_default()?
145145
```
146146

147+
`UniError<T>` --> `UniError<U>` (`U` implements `From<T>`):
148+
149+
```text
150+
result.kind_into()?
151+
```
152+
153+
147154
`Option<V>`:
148155

149156
```text
150-
option.wrap()?
157+
option.kind_default()?
151158
```
152159

153160
Fallback for `std::fmt::Display` types:
154161

155162
```text
156-
result.wrap_disp()?
163+
result.kind_default_disp()?
157164
```
158165

159166
### How does equality work?

examples/map_kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn try_something() -> UniResult<(), ErrKind1> {
3333
}
3434

3535
fn try_something_else() -> UniResult<(), ErrKind2> {
36-
try_something().map_kind(|err, old_kind| {
36+
try_something().kind_map(|err, old_kind| {
3737
err.kind_context(ErrKind2::ErrKind1(old_kind), "something bad happened")
3838
})
3939
}

0 commit comments

Comments
 (0)