{"action":"closed","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/50241","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/50241/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/50241/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/50241/events","html_url":"https://github.com/rust-lang/rust/issues/50241","id":317858942,"number":50241,"title":"Accessing std::time::Instant internals","user":{"login":"hetmankp","id":728670,"avatar_url":"https://avatars3.githubusercontent.com/u/728670?v=4","gravatar_id":"","url":"https://api.github.com/users/hetmankp","html_url":"https://github.com/hetmankp","followers_url":"https://api.github.com/users/hetmankp/followers","following_url":"https://api.github.com/users/hetmankp/following{/other_user}","gists_url":"https://api.github.com/users/hetmankp/gists{/gist_id}","starred_url":"https://api.github.com/users/hetmankp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hetmankp/subscriptions","organizations_url":"https://api.github.com/users/hetmankp/orgs","repos_url":"https://api.github.com/users/hetmankp/repos","events_url":"https://api.github.com/users/hetmankp/events{/privacy}","received_events_url":"https://api.github.com/users/hetmankp/received_events","type":"User","site_admin":false},"labels":[{"id":630652267,"url":"https://api.github.com/repos/rust-lang/rust/labels/C-feature-request","name":"C-feature-request","color":"f5f1fd","default":false},{"id":211668062,"url":"https://api.github.com/repos/rust-lang/rust/labels/T-libs","name":"T-libs","color":"bfd4f2","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-26T02:50:39Z","updated_at":"2018-05-02T04:14:29Z","closed_at":"2018-05-02T04:14:29Z","author_association":"NONE","body":"Currently it's difficult to test any code using `std::time::Instant` because of its opacity. While it's possible to do per project mocking I was wondering if there would be any interest in making testing easier by opening up the interface a bit. For example:\r\n\r\n```rust\r\nmod std::time {\r\n    use sys::time;\r\n\r\n    Instant {\r\n        pub fn from_internal(internal: time::Instant) -> Instant;\r\n        pub fn to_internal(self) -> time::Instant;\r\n    }\r\n}\r\n\r\nmod std::sys::unix::time {\r\n    Instant {\r\n        pub fn from_internal(internal: u64) -> Instant;\r\n        pub fn to_internal(self) -> u64;\r\n    }\r\n}\r\n```\r\n\r\nThere may be other situations where access to the internals may be useful and although the above interfaces may discourage purity, they're unwieldy enough that I don't think abuse would be common."}}
{"actor":{"display_login":"sfackler"}}