{"action":"created","issue":{"url":"https://api.github.com/repos/carllerche/nix-rust/issues/56","labels_url":"https://api.github.com/repos/carllerche/nix-rust/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/carllerche/nix-rust/issues/56/comments","events_url":"https://api.github.com/repos/carllerche/nix-rust/issues/56/events","html_url":"https://github.com/carllerche/nix-rust/pull/56","id":56059165,"number":56,"title":"Replace all uses of `Path` with `CString`.","user":{"login":"utkarshkukreti","id":217126,"avatar_url":"https://avatars.githubusercontent.com/u/217126?v=3","gravatar_id":"","url":"https://api.github.com/users/utkarshkukreti","html_url":"https://github.com/utkarshkukreti","followers_url":"https://api.github.com/users/utkarshkukreti/followers","following_url":"https://api.github.com/users/utkarshkukreti/following{/other_user}","gists_url":"https://api.github.com/users/utkarshkukreti/gists{/gist_id}","starred_url":"https://api.github.com/users/utkarshkukreti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utkarshkukreti/subscriptions","organizations_url":"https://api.github.com/users/utkarshkukreti/orgs","repos_url":"https://api.github.com/users/utkarshkukreti/repos","events_url":"https://api.github.com/users/utkarshkukreti/events{/privacy}","received_events_url":"https://api.github.com/users/utkarshkukreti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-01-30T17:11:00Z","updated_at":"2015-02-06T16:09:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/carllerche/nix-rust/pulls/56","html_url":"https://github.com/carllerche/nix-rust/pull/56","diff_url":"https://github.com/carllerche/nix-rust/pull/56.diff","patch_url":"https://github.com/carllerche/nix-rust/pull/56.patch"},"body":"All the `Path`s were being converted to `CString`s on every call to any\r\nfunction that accepted them, which is an unnecessary allocation (and the\r\npossibility of a panic which should probably happen outside the\r\nfunctions in this crate) which can be easily avoided now.\r\n\r\nYou can fix existing code by converting `Path`s to `CString` using\r\nsomething like:\r\n\r\n    CString::from_slice(path.container_as_bytes())\r\n\r\nand then passing that to the function(s).\r\n\r\nOr just not create `Path`s and pass a `&[u8]` to `CString::from_slice`\r\ndirectly.\r\n\r\n    foo(&Path::new(\"...\"))\r\n\r\nto\r\n\r\n    foo(&CString::from_slice(b\"...\"))\r\n\r\n[breaking-change]"},"comment":{"url":"https://api.github.com/repos/carllerche/nix-rust/issues/comments/73261032","html_url":"https://github.com/carllerche/nix-rust/pull/56#issuecomment-73261032","issue_url":"https://api.github.com/repos/carllerche/nix-rust/issues/56","id":73261032,"user":{"login":"utkarshkukreti","id":217126,"avatar_url":"https://avatars.githubusercontent.com/u/217126?v=3","gravatar_id":"","url":"https://api.github.com/users/utkarshkukreti","html_url":"https://github.com/utkarshkukreti","followers_url":"https://api.github.com/users/utkarshkukreti/followers","following_url":"https://api.github.com/users/utkarshkukreti/following{/other_user}","gists_url":"https://api.github.com/users/utkarshkukreti/gists{/gist_id}","starred_url":"https://api.github.com/users/utkarshkukreti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utkarshkukreti/subscriptions","organizations_url":"https://api.github.com/users/utkarshkukreti/orgs","repos_url":"https://api.github.com/users/utkarshkukreti/repos","events_url":"https://api.github.com/users/utkarshkukreti/events{/privacy}","received_events_url":"https://api.github.com/users/utkarshkukreti/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T16:09:48Z","updated_at":"2015-02-06T16:09:48Z","body":"@carllerche does this look like it's going in the right direction: https://gist.github.com/464d19a5bb305ea4098c? I still need to shuffle around some functions and test on Linux."}}