{"action":"created","comment":{"url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/comments/39660427","id":39660427,"diff_hunk":"@@ -0,0 +1,434 @@\n+//! Port of BSP toolkit.\n+\n+use bindings::ffi;\n+use bindings::AsNative;\n+use bindings::{c_void, c_bool};\n+use random::Rng;\n+use std::ops::{Deref, DerefMut};\n+\n+#[derive(Copy, Clone, Debug)]\n+pub enum TraverseOrder {\n+    PreOrder,\n+    InOrder,\n+    PostOrder,\n+    LevelOrder,\n+    InvertedLevelOrder,\n+}\n+\n+/// This struct encapsulates `TCOD_bsp_t`. It mirrors original's fields (`x`, `y`, etc.)\n+/// with the exception of `horizontal`. See example.\n+///\n+/// # Examples\n+///\n+/// ```no_run\n+/// # use tcod::bsp::*;\n+/// let mut bsp = Bsp::new_with_size(0, 0, 50, 60);\n+///\n+/// assert_eq!(bsp.x, 0);\n+/// assert_eq!(bsp.y, 0);\n+/// assert_eq!(bsp.w, 50);\n+/// assert_eq!(bsp.h, 60);\n+/// assert_eq!(bsp.horizontal(), false);\n+///\n+/// bsp.x = 10;\n+/// bsp.y = 20;\n+/// bsp.set_horizontal(true);\n+/// ```\n+pub struct Bsp {\n+    bsp: *mut ffi::TCOD_bsp_t,\n+    root: bool\n+}\n+\n+impl Deref for Bsp {","path":"src/bsp.rs","position":42,"original_position":42,"commit_id":"ea32bbb10bcdbf76dac1ce4581927bdb254d18df","original_commit_id":"d4a05d8d2b5e549278d638b05f14b379c9761f50","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},"body":"I didn't mean accessors. Just define a struct: \r\n\r\n```rust\r\n#[repr(C)]\r\nstruct Bsp {\r\n    tree: TCOD_bsp_t,    \r\n    // All other Bsp members made public, matching the declaration order of the C struct\r\n}\r\n```\r\n\r\nThen you can just create an instance of the C struct an directly transmute it into the Rust version. It should be a free operation and hides the ugly unsafe pointer in the Rust API.","created_at":"2015-09-16T17:35:26Z","updated_at":"2015-09-16T17:35:26Z","html_url":"https://github.com/tomassedovic/tcod-rs/pull/198#discussion_r39660427","pull_request_url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198","_links":{"self":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/comments/39660427"},"html":{"href":"https://github.com/tomassedovic/tcod-rs/pull/198#discussion_r39660427"},"pull_request":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198"}}},"pull_request":{"url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198","id":44715783,"html_url":"https://github.com/tomassedovic/tcod-rs/pull/198","diff_url":"https://github.com/tomassedovic/tcod-rs/pull/198.diff","patch_url":"https://github.com/tomassedovic/tcod-rs/pull/198.patch","issue_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/198","number":198,"state":"open","locked":false,"title":"BSP toolkit","user":{"login":"tomob","id":1015581,"avatar_url":"https://avatars.githubusercontent.com/u/1015581?v=3","gravatar_id":"","url":"https://api.github.com/users/tomob","html_url":"https://github.com/tomob","followers_url":"https://api.github.com/users/tomob/followers","following_url":"https://api.github.com/users/tomob/following{/other_user}","gists_url":"https://api.github.com/users/tomob/gists{/gist_id}","starred_url":"https://api.github.com/users/tomob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomob/subscriptions","organizations_url":"https://api.github.com/users/tomob/orgs","repos_url":"https://api.github.com/users/tomob/repos","events_url":"https://api.github.com/users/tomob/events{/privacy}","received_events_url":"https://api.github.com/users/tomob/received_events","type":"User","site_admin":false},"body":"BSP toolkit and related example.","created_at":"2015-09-10T20:34:01Z","updated_at":"2015-09-16T17:35:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e960786a7924cc5030d5bdc4d0086ea85d1728e2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198/commits","review_comments_url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198/comments","review_comment_url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/198/comments","statuses_url":"https://api.github.com/repos/tomassedovic/tcod-rs/statuses/ea32bbb10bcdbf76dac1ce4581927bdb254d18df","head":{"label":"tomob:bsp","ref":"bsp","sha":"ea32bbb10bcdbf76dac1ce4581927bdb254d18df","user":{"login":"tomob","id":1015581,"avatar_url":"https://avatars.githubusercontent.com/u/1015581?v=3","gravatar_id":"","url":"https://api.github.com/users/tomob","html_url":"https://github.com/tomob","followers_url":"https://api.github.com/users/tomob/followers","following_url":"https://api.github.com/users/tomob/following{/other_user}","gists_url":"https://api.github.com/users/tomob/gists{/gist_id}","starred_url":"https://api.github.com/users/tomob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomob/subscriptions","organizations_url":"https://api.github.com/users/tomob/orgs","repos_url":"https://api.github.com/users/tomob/repos","events_url":"https://api.github.com/users/tomob/events{/privacy}","received_events_url":"https://api.github.com/users/tomob/received_events","type":"User","site_admin":false},"repo":{"id":40916418,"name":"tcod-rs","full_name":"tomob/tcod-rs","owner":{"login":"tomob","id":1015581,"avatar_url":"https://avatars.githubusercontent.com/u/1015581?v=3","gravatar_id":"","url":"https://api.github.com/users/tomob","html_url":"https://github.com/tomob","followers_url":"https://api.github.com/users/tomob/followers","following_url":"https://api.github.com/users/tomob/following{/other_user}","gists_url":"https://api.github.com/users/tomob/gists{/gist_id}","starred_url":"https://api.github.com/users/tomob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomob/subscriptions","organizations_url":"https://api.github.com/users/tomob/orgs","repos_url":"https://api.github.com/users/tomob/repos","events_url":"https://api.github.com/users/tomob/events{/privacy}","received_events_url":"https://api.github.com/users/tomob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tomob/tcod-rs","description":"Rust bindings for libtcod 1.5.1 (the Doryen library/roguelike toolkit)","fork":true,"url":"https://api.github.com/repos/tomob/tcod-rs","forks_url":"https://api.github.com/repos/tomob/tcod-rs/forks","keys_url":"https://api.github.com/repos/tomob/tcod-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomob/tcod-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomob/tcod-rs/teams","hooks_url":"https://api.github.com/repos/tomob/tcod-rs/hooks","issue_events_url":"https://api.github.com/repos/tomob/tcod-rs/issues/events{/number}","events_url":"https://api.github.com/repos/tomob/tcod-rs/events","assignees_url":"https://api.github.com/repos/tomob/tcod-rs/assignees{/user}","branches_url":"https://api.github.com/repos/tomob/tcod-rs/branches{/branch}","tags_url":"https://api.github.com/repos/tomob/tcod-rs/tags","blobs_url":"https://api.github.com/repos/tomob/tcod-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomob/tcod-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomob/tcod-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomob/tcod-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomob/tcod-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/tomob/tcod-rs/languages","stargazers_url":"https://api.github.com/repos/tomob/tcod-rs/stargazers","contributors_url":"https://api.github.com/repos/tomob/tcod-rs/contributors","subscribers_url":"https://api.github.com/repos/tomob/tcod-rs/subscribers","subscription_url":"https://api.github.com/repos/tomob/tcod-rs/subscription","commits_url":"https://api.github.com/repos/tomob/tcod-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomob/tcod-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomob/tcod-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomob/tcod-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/tomob/tcod-rs/contents/{+path}","compare_url":"https://api.github.com/repos/tomob/tcod-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomob/tcod-rs/merges","archive_url":"https://api.github.com/repos/tomob/tcod-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomob/tcod-rs/downloads","issues_url":"https://api.github.com/repos/tomob/tcod-rs/issues{/number}","pulls_url":"https://api.github.com/repos/tomob/tcod-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/tomob/tcod-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/tomob/tcod-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomob/tcod-rs/labels{/name}","releases_url":"https://api.github.com/repos/tomob/tcod-rs/releases{/id}","created_at":"2015-08-17T17:58:35Z","updated_at":"2015-08-17T17:58:37Z","pushed_at":"2015-09-14T13:11:38Z","git_url":"git://github.com/tomob/tcod-rs.git","ssh_url":"git@github.com:tomob/tcod-rs.git","clone_url":"https://github.com/tomob/tcod-rs.git","svn_url":"https://github.com/tomob/tcod-rs","homepage":"","size":6504,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tomassedovic:master","ref":"master","sha":"cedb334d0c41be905d2d40adbe61e11b39903c41","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},"repo":{"id":20941939,"name":"tcod-rs","full_name":"tomassedovic/tcod-rs","owner":{"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},"private":false,"html_url":"https://github.com/tomassedovic/tcod-rs","description":"Rust bindings for libtcod 1.5.1 (the Doryen library/roguelike toolkit)","fork":false,"url":"https://api.github.com/repos/tomassedovic/tcod-rs","forks_url":"https://api.github.com/repos/tomassedovic/tcod-rs/forks","keys_url":"https://api.github.com/repos/tomassedovic/tcod-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomassedovic/tcod-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomassedovic/tcod-rs/teams","hooks_url":"https://api.github.com/repos/tomassedovic/tcod-rs/hooks","issue_events_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/events{/number}","events_url":"https://api.github.com/repos/tomassedovic/tcod-rs/events","assignees_url":"https://api.github.com/repos/tomassedovic/tcod-rs/assignees{/user}","branches_url":"https://api.github.com/repos/tomassedovic/tcod-rs/branches{/branch}","tags_url":"https://api.github.com/repos/tomassedovic/tcod-rs/tags","blobs_url":"https://api.github.com/repos/tomassedovic/tcod-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomassedovic/tcod-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomassedovic/tcod-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomassedovic/tcod-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomassedovic/tcod-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/tomassedovic/tcod-rs/languages","stargazers_url":"https://api.github.com/repos/tomassedovic/tcod-rs/stargazers","contributors_url":"https://api.github.com/repos/tomassedovic/tcod-rs/contributors","subscribers_url":"https://api.github.com/repos/tomassedovic/tcod-rs/subscribers","subscription_url":"https://api.github.com/repos/tomassedovic/tcod-rs/subscription","commits_url":"https://api.github.com/repos/tomassedovic/tcod-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomassedovic/tcod-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomassedovic/tcod-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/tomassedovic/tcod-rs/contents/{+path}","compare_url":"https://api.github.com/repos/tomassedovic/tcod-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomassedovic/tcod-rs/merges","archive_url":"https://api.github.com/repos/tomassedovic/tcod-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomassedovic/tcod-rs/downloads","issues_url":"https://api.github.com/repos/tomassedovic/tcod-rs/issues{/number}","pulls_url":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/tomassedovic/tcod-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/tomassedovic/tcod-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomassedovic/tcod-rs/labels{/name}","releases_url":"https://api.github.com/repos/tomassedovic/tcod-rs/releases{/id}","created_at":"2014-06-17T22:43:56Z","updated_at":"2015-08-30T22:50:36Z","pushed_at":"2015-09-14T13:11:39Z","git_url":"git://github.com/tomassedovic/tcod-rs.git","ssh_url":"git@github.com:tomassedovic/tcod-rs.git","clone_url":"https://github.com/tomassedovic/tcod-rs.git","svn_url":"https://github.com/tomassedovic/tcod-rs","homepage":"","size":8794,"stargazers_count":41,"watchers_count":41,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":19,"mirror_url":null,"open_issues_count":6,"forks":19,"open_issues":6,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198"},"html":{"href":"https://github.com/tomassedovic/tcod-rs/pull/198"},"issue":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/198"},"comments":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/issues/198/comments"},"review_comments":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198/comments"},"review_comment":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/pulls/198/commits"},"statuses":{"href":"https://api.github.com/repos/tomassedovic/tcod-rs/statuses/ea32bbb10bcdbf76dac1ce4581927bdb254d18df"}}}}