{"action":"created","issue":{"url":"https://api.github.com/repos/starkat99/half-rs/issues/14","repository_url":"https://api.github.com/repos/starkat99/half-rs","labels_url":"https://api.github.com/repos/starkat99/half-rs/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/starkat99/half-rs/issues/14/comments","events_url":"https://api.github.com/repos/starkat99/half-rs/issues/14/events","html_url":"https://github.com/starkat99/half-rs/issues/14","id":355549387,"node_id":"MDU6SXNzdWUzNTU1NDkzODc=","number":14,"title":"Convert an u16 array to f16 array","user":{"login":"johannesvollmer","id":32042925,"node_id":"MDQ6VXNlcjMyMDQyOTI1","avatar_url":"https://avatars0.githubusercontent.com/u/32042925?v=4","gravatar_id":"","url":"https://api.github.com/users/johannesvollmer","html_url":"https://github.com/johannesvollmer","followers_url":"https://api.github.com/users/johannesvollmer/followers","following_url":"https://api.github.com/users/johannesvollmer/following{/other_user}","gists_url":"https://api.github.com/users/johannesvollmer/gists{/gist_id}","starred_url":"https://api.github.com/users/johannesvollmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johannesvollmer/subscriptions","organizations_url":"https://api.github.com/users/johannesvollmer/orgs","repos_url":"https://api.github.com/users/johannesvollmer/repos","events_url":"https://api.github.com/users/johannesvollmer/events{/privacy}","received_events_url":"https://api.github.com/users/johannesvollmer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-30T11:48:06Z","updated_at":"2018-08-30T11:53:45Z","closed_at":null,"author_association":"NONE","body":"I am currently implementing a file format which stores f16 arrays. As `byteorder` does not support f16, I need to serialize these f16 arrays as u16 arrays and then convert to f16.\r\n\r\nI wondered if there could be some functionality in this library, which prevents users to just do `array.iter().map(|u| f16::from_bits(u)).collect::<Vec<f16>>()`. This code iterates the whole array and allocates a new vector, but (I assume that) in memory, not a single bit is changed. All it probably does is basically copying the contents of the array element by element. But all it needs to do is basically just interpret the bits in a different way by representing it with a different type at compile time. \r\n\r\nIs it maybe possible to reinterpret an array of u16 as an array of f16 by simply unsafely casting the raw pointers?\r\n\r\nIf not, certainly it's possible to provide an `F16Slice <'a> (&'a [u16])` which maybe even implements `::std::ops::Index` with `f16::from_bits(self.0[index])`, or something similar.\r\n\r\nOn the other hand, I can imagine that my use case is rather rare and not many people need to convert between large arrays of u16 and f16. Anyways, what do you think of that?\r\n\r\n_Also, Please correct me if I have overlooked something._"},"comment":{"url":"https://api.github.com/repos/starkat99/half-rs/issues/comments/417292446","html_url":"https://github.com/starkat99/half-rs/issues/14#issuecomment-417292446","issue_url":"https://api.github.com/repos/starkat99/half-rs/issues/14","id":417292446,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzI5MjQ0Ng==","user":{"login":"johannesvollmer","id":32042925,"node_id":"MDQ6VXNlcjMyMDQyOTI1","avatar_url":"https://avatars0.githubusercontent.com/u/32042925?v=4","gravatar_id":"","url":"https://api.github.com/users/johannesvollmer","html_url":"https://github.com/johannesvollmer","followers_url":"https://api.github.com/users/johannesvollmer/followers","following_url":"https://api.github.com/users/johannesvollmer/following{/other_user}","gists_url":"https://api.github.com/users/johannesvollmer/gists{/gist_id}","starred_url":"https://api.github.com/users/johannesvollmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johannesvollmer/subscriptions","organizations_url":"https://api.github.com/users/johannesvollmer/orgs","repos_url":"https://api.github.com/users/johannesvollmer/repos","events_url":"https://api.github.com/users/johannesvollmer/events{/privacy}","received_events_url":"https://api.github.com/users/johannesvollmer/received_events","type":"User","site_admin":false},"created_at":"2018-08-30T11:53:45Z","updated_at":"2018-08-30T11:53:45Z","author_association":"NONE","body":"Update: implementing `::std::ops::Index` probably does not work naively, because `Index` returns a ŕeference and not a value."}}
{"actor":{"display_login":"johannesvollmer"}}