Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

A method for iterating over causes #41

Closed
epage opened this issue Nov 14, 2017 · 3 comments
Closed

A method for iterating over causes #41

epage opened this issue Nov 14, 2017 · 3 comments

Comments

@epage
Copy link

epage commented Nov 14, 2017

Currently there is cause and root_cause.

It'd be nice to have something like iter_causes to help in cases like this

println!("Error: {}", err);
let mut cause = err.cause();
while let Some(c) = cause {
    println!("Caused by: {}", c);
    cause = c.cause();
}

to

println!("Error: {}", err);
for cause in err.iter_causes() {
    println!("Caused by: {}", cause);
}
@withoutboats
Copy link
Contributor

I'm open to it, but I think not in 0.1. For now the while let loop is not so bad.

@epage
Copy link
Author

epage commented Nov 15, 2017

I'm fine with it being a lower priority

@withoutboats
Copy link
Contributor

#54 resolved this issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants