{"action":"created","issue":{"url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/193","labels_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/193/comments","events_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/193/events","html_url":"https://github.com/tomassedovic/tcod-rs/pull/193","id":104094446,"number":193,"title":"Safe iterable/wrapping enums","user":{"login":"Gustorn","id":2189776,"avatar_url":"https://avatars.githubusercontent.com/u/2189776?v=3","gravatar_id":"","url":"https://api.github.com/users/Gustorn","html_url":"https://github.com/Gustorn","followers_url":"https://api.github.com/users/Gustorn/followers","following_url":"https://api.github.com/users/Gustorn/following{/other_user}","gists_url":"https://api.github.com/users/Gustorn/gists{/gist_id}","starred_url":"https://api.github.com/users/Gustorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gustorn/subscriptions","organizations_url":"https://api.github.com/users/Gustorn/orgs","repos_url":"https://api.github.com/users/Gustorn/repos","events_url":"https://api.github.com/users/Gustorn/events{/privacy}","received_events_url":"https://api.github.com/users/Gustorn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-31T17:20:05Z","updated_at":"2015-09-04T08:18:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/193","html_url":"https://github.com/tomassedovic/tcod-rs/pull/193","diff_url":"https://github.com/tomassedovic/tcod-rs/pull/193.diff","patch_url":"https://github.com/tomassedovic/tcod-rs/pull/193.patch"},"body":"An example for safe iterable/wrapping enum implementation: I realize that providing this functionality as part of the library is questionable, but there is a problem with providing this implementation in the examples (or leaving it to the users): the `mem::transmute(enum as i32 + 1)` trick is not guaranteed to last forever, upstream could decide (for some reason) to assign actual values to these enums. This version will at least catch the error if you run `cargo test`.\r\n\r\nThe other question is: is this really necessary? It sure as hell is nice with the `samples` code (especially once #191 is merged), but I don't really see this as something I would use every day. "},"comment":{"url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/comments/137675969","html_url":"https://github.com/tomassedovic/tcod-rs/pull/193#issuecomment-137675969","issue_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/193","id":137675969,"user":{"login":"tomassedovic","id":104339,"avatar_url":"https://avatars.githubusercontent.com/u/104339?v=3","gravatar_id":"","url":"https://api.github.com/users/tomassedovic","html_url":"https://github.com/tomassedovic","followers_url":"https://api.github.com/users/tomassedovic/followers","following_url":"https://api.github.com/users/tomassedovic/following{/other_user}","gists_url":"https://api.github.com/users/tomassedovic/gists{/gist_id}","starred_url":"https://api.github.com/users/tomassedovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomassedovic/subscriptions","organizations_url":"https://api.github.com/users/tomassedovic/orgs","repos_url":"https://api.github.com/users/tomassedovic/repos","events_url":"https://api.github.com/users/tomassedovic/events{/privacy}","received_events_url":"https://api.github.com/users/tomassedovic/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T08:18:15Z","updated_at":"2015-09-04T08:18:15Z","body":"I keep going back and forth on this. It would make the samples code simpler, but you're right, I don't see cycling between background flags or available renderers a common thing to do either.\r\n\r\nI'm still hoping that we'll get proper iteration and prev/next cycling of enums in Rust or at least through a common plugin, but yeah, maybe baking it here is not the ideal solution since it's probably usable just in the samples example.\r\n\r\nI wonder if we could implement cycles and iteration directly there. Ideally with a full match rather than transmute. A macro could help us simplify that."}}