{"action":"closed","issue":{"url":"https://api.github.com/repos/pyfisch/cbor/issues/5","repository_url":"https://api.github.com/repos/pyfisch/cbor","labels_url":"https://api.github.com/repos/pyfisch/cbor/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/pyfisch/cbor/issues/5/comments","events_url":"https://api.github.com/repos/pyfisch/cbor/issues/5/events","html_url":"https://github.com/pyfisch/cbor/issues/5","id":134350429,"number":5,"title":"`Option<T>` does not round-trip","user":{"login":"apoelstra","id":1351933,"avatar_url":"https://avatars.githubusercontent.com/u/1351933?v=3","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-17T17:43:00Z","updated_at":"2016-03-30T10:48:52Z","closed_at":"2016-03-30T10:48:52Z","body":"```\r\nextern crate serde_cbor;\r\n\r\nfn main() {\r\n    let obj1 = Some(10u32);\r\n\r\n    let mut v = vec![];\r\n    assert!(serde_cbor::ser::to_writer(&mut v, &obj1).is_ok());\r\n    println!(\"{:?}\", v);\r\n    let obj2: Result<Option<u32>, _> = serde_cbor::de::from_reader(&v[..]);\r\n\r\n    assert_eq!(obj1, obj2.unwrap());\r\n}\r\n```\r\nThis code fails with\r\n```thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: SyntaxError(invalid syntax: \"incorrect type\", 0)', ../src/libcore/result.rs:738```\r\n\r\nI have code in production that fails with \"trailing bytes\" when I have a structure whose last element is an Option; I haven't produced a small test case because it's such a PITA to write Serialize/Deserialize impls for structures."}}