{"action":"created","issue":{"url":"https://api.github.com/repos/tailhook/quick-error/issues/28","repository_url":"https://api.github.com/repos/tailhook/quick-error","labels_url":"https://api.github.com/repos/tailhook/quick-error/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/tailhook/quick-error/issues/28/comments","events_url":"https://api.github.com/repos/tailhook/quick-error/issues/28/events","html_url":"https://github.com/tailhook/quick-error/pull/28","id":170571334,"number":28,"title":"Add support for `cause()` when error is Box<Error>","user":{"login":"Byron","id":63622,"avatar_url":"https://avatars.githubusercontent.com/u/63622?v=3","gravatar_id":"","url":"https://api.github.com/users/Byron","html_url":"https://github.com/Byron","followers_url":"https://api.github.com/users/Byron/followers","following_url":"https://api.github.com/users/Byron/following{/other_user}","gists_url":"https://api.github.com/users/Byron/gists{/gist_id}","starred_url":"https://api.github.com/users/Byron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Byron/subscriptions","organizations_url":"https://api.github.com/users/Byron/orgs","repos_url":"https://api.github.com/users/Byron/repos","events_url":"https://api.github.com/users/Byron/events{/privacy}","received_events_url":"https://api.github.com/users/Byron/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-08-11T05:06:58Z","updated_at":"2016-08-20T13:37:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tailhook/quick-error/pulls/28","html_url":"https://github.com/tailhook/quick-error/pull/28","diff_url":"https://github.com/tailhook/quick-error/pull/28.diff","patch_url":"https://github.com/tailhook/quick-error/pull/28.patch"},"body":"Sometimes one wants to support any kind of error, and without\r\nsupport for generics, using a `Box` is the only way.\r\n\r\nPreviously `cause(err)` would not work as one cannot automatically\r\nconvert `Box<Error>` into `Option<&Error>`. However, the `Borrow`\r\ntrait will make it work for boxes as well as for simple references.\r\n\r\nPlease note that the current implementation does not (yet) support\r\npartial equality.\r\n\r\nThanks to [Francis Gagné][SO] for helping me figuring it out.\r\n\r\n[SO]: http://stackoverflow.com/questions/38842875/how-to-use-quick-error-with-boxed-error-types/38885994#38885994"},"comment":{"url":"https://api.github.com/repos/tailhook/quick-error/issues/comments/241200572","html_url":"https://github.com/tailhook/quick-error/pull/28#issuecomment-241200572","issue_url":"https://api.github.com/repos/tailhook/quick-error/issues/28","id":241200572,"user":{"login":"colin-kiegel","id":7691186,"avatar_url":"https://avatars.githubusercontent.com/u/7691186?v=3","gravatar_id":"","url":"https://api.github.com/users/colin-kiegel","html_url":"https://github.com/colin-kiegel","followers_url":"https://api.github.com/users/colin-kiegel/followers","following_url":"https://api.github.com/users/colin-kiegel/following{/other_user}","gists_url":"https://api.github.com/users/colin-kiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/colin-kiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colin-kiegel/subscriptions","organizations_url":"https://api.github.com/users/colin-kiegel/orgs","repos_url":"https://api.github.com/users/colin-kiegel/repos","events_url":"https://api.github.com/users/colin-kiegel/events{/privacy}","received_events_url":"https://api.github.com/users/colin-kiegel/received_events","type":"User","site_admin":false},"created_at":"2016-08-20T13:37:45Z","updated_at":"2016-08-20T13:37:45Z","body":"Ok, I have changed my mind. :-)\r\n\r\nFor these reasons:\r\n* What if people want to use variants like `Any(Box<Rc<Error>>)` - neither `deref` nor `borrow` seem to work here\r\n* I somehow forgot that it is indeed possible to do it with quick-error, because we match on expressions and not idents: `cause(&**err)` in case of `Box<Err>`.\r\n* There seems to be something wrong with deref and lifetimes in match statements (I currently suspect a rustc bug, but maybe I'm wrong)\r\n\r\nhttps://play.rust-lang.org/?gist=b4707c4f49ce336c0db2dd90a0e73bb6&version=nightly&backtrace=0\r\n\r\nThis is working:\r\n\r\n```rust\r\n#[macro_use] extern crate quick_error;\r\n\r\n#[allow(dead_code)]\r\nquick_error!{\r\n    #[derive(Debug)]\r\n    pub enum MyError {\r\n        Any(err: Box<::std::error::Error>) {\r\n            cause(&**err)\r\n        }\r\n    }\r\n}\r\n\r\nfn main() {}\r\n```\r\n\r\n@Byron Is it ok for you to do the deref/borrow (whatever you like) in the definition of the error? If this is good enough for you, you could still contribute by extending the examples and documentation for this case (@tailhook if that is ok for you ^^)."}}
{"actor":{"display_login":"colin-kiegel"}}