{"action":"closed","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/3795","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/3795/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/3795/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/3795/events","html_url":"https://github.com/rust-lang/rust/issues/3795","id":7667448,"number":3795,"title":"Need a mechanism to write rust-version-specific code","user":{"login":"erickt","id":84711,"avatar_url":"https://avatars.githubusercontent.com/u/84711?v=3","gravatar_id":"","url":"https://api.github.com/users/erickt","html_url":"https://github.com/erickt","followers_url":"https://api.github.com/users/erickt/followers","following_url":"https://api.github.com/users/erickt/following{/other_user}","gists_url":"https://api.github.com/users/erickt/gists{/gist_id}","starred_url":"https://api.github.com/users/erickt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erickt/subscriptions","organizations_url":"https://api.github.com/users/erickt/orgs","repos_url":"https://api.github.com/users/erickt/repos","events_url":"https://api.github.com/users/erickt/events{/privacy}","received_events_url":"https://api.github.com/users/erickt/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-attributes","name":"A-attributes","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/E-easy","name":"E-easy","color":"02e10c"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-enhancement","name":"I-enhancement","color":"e10c02"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-low","name":"P-low","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2012-10-17T20:00:46Z","updated_at":"2015-01-21T21:44:43Z","closed_at":"2015-01-21T21:44:43Z","body":"Since rust is still going through active development, it's hard to write a library that works for both rust-0.4 and rust-incoming. We need a cfg  `#[cfg(rust_version=\"0.5\")]` to carve off chunks of code that have evolved in between versions.\r\n\r\nIf we want to get more fancy with these controls, I do have an old [semantic version parser](https://github.com/erickt/rust-semver) I wrote back in the 0.3 days. Maybe we could use something like that to let us write checks like:\r\n\r\n```\r\n#[cfg(rust_version=\">=0.4-beta\")]\r\n#[cfg(rust_version=\"<=0.4\")]\r\nfn foo() { ... }\r\n\r\n#[cfg(rust_version=\">0.5\")]\r\nfn foo() { ... }\r\n```"}}