{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/34250","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/34250/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/34250/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/34250/events","html_url":"https://github.com/rust-lang/rust/issues/34250","id":159856677,"number":34250,"title":"Book section on FFI with nullable pointers doesn't explain None == null.","user":{"login":"eddyb","id":77424,"avatar_url":"https://avatars.githubusercontent.com/u/77424?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-book","name":"A-book","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-13T00:32:46Z","updated_at":"2016-06-13T10:39:35Z","closed_at":null,"body":"The paragraph in question (https://doc.rust-lang.org/book/ffi.html#the-nullable-pointer-optimization):\r\n\r\n> # The \"nullable pointer optimization\"\r\n\r\n> Certain types are defined to not be `null`. This includes references (`&T`,\r\n> `&mut T`), boxes (`Box<T>`), and function pointers (`extern \"abi\" fn()`).\r\n> When interfacing with C, pointers that might be null are often used.\r\n> As a special case, a generic `enum` that contains exactly two variants, one of\r\n> which contains no data and the other containing a single field, is eligible\r\n> for the \"nullable pointer optimization\". When such an enum is instantiated\r\n> with one of the non-nullable types, it is represented as a single pointer,\r\n> and the non-data variant is represented as the null pointer. So\r\n> `Option<extern \"C\" fn(c_int) -> c_int>` is how one represents a nullable\r\n> function pointer using the C ABI.\r\n\r\nWhile the paragraph does a good job at explaining when this optimizations happens (although it's missing the fact that the optimization can now look for deeply nested fields to use), it doesn't explicitly mention that `None` represents the \"NULL\" value and that `Some(function)` is how you create non-\"NULL\" values, nor does it have a code example.\r\n\r\nWhat this can lead to is code that transmutes because it might not be entirely clear that there's a safe way to create values of that type.\r\n\r\ncc @steveklabnik"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/225546747","html_url":"https://github.com/rust-lang/rust/issues/34250#issuecomment-225546747","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34250","id":225546747,"user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T10:39:34Z","updated_at":"2016-06-13T10:39:34Z","body":"http://rust-lang.github.io/book\n\n\nOn Jun 13, 2016, 10:50 +0200, Sander Maijers<notifications@github.com>, wrote:\n>  \n> @steveklabnik(https://github.com/steveklabnik): could you point me to the new book?\n>  \n>  \n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly,view it on GitHub(https://github.com/rust-lang/rust/issues/34250#issuecomment-225522869), ormute the thread(https://github.com/notifications/unsubscribe/AABsitYnLLzgpXoVLLAX5tX9Kd_-ZOTVks5qLRm7gaJpZM4Iz7G5).\n>  \n>  \n>  \n\n\n"}}
{"actor":{"display_login":"steveklabnik"}}