{"action":"created","comment":{"url":"https://api.github.com/repos/iwburns/id-tree/pulls/comments/93522199","pull_request_review_id":14052227,"id":93522199,"diff_hunk":"@@ -625,6 +627,128 @@ impl<T> Tree<T> {\n     }\n \n     ///\n+    /// Swaps two `Node`s including their children given their `NodeId`s.\n+    ///\n+    /// Returns an empty `Result` containing a `NodeIdError` if one occurred on either provided `Id`.\n+    ///\n+    /// Notes:\n+    ///     - Both `NodeId`s are still valid after this process and are not swapped.\n+    ///     - Keeps the positions of the `Node`s in their parents children collection.\n+    ///\n+    /// ```\n+    /// use id_tree::Tree;\n+    /// use id_tree::Node;\n+    ///\n+    /// let root_node = Node::new(1);\n+    /// let first_child_node = Node::new(2);\n+    /// let second_child_node = Node::new(3);\n+    /// let grandchild_node = Node::new(4);\n+    ///\n+    /// let mut tree: Tree<i32> = Tree::new();\n+    /// let root_id = tree.set_root(root_node);\n+    ///\n+    /// let first_child_id  = tree.insert_with_parent(first_child_node,  &root_id).ok().unwrap();\n+    /// let second_child_id = tree.insert_with_parent(second_child_node, &root_id).ok().unwrap();\n+    /// let grandchild_id   = tree.insert_with_parent(grandchild_node, &second_child_id).unwrap();\n+    ///\n+    /// tree.swap_sub_tree(&first_child_id, &grandchild_id).unwrap();\n+    ///\n+    /// assert!(tree.get(&second_child_id).unwrap().children().contains(&first_child_id));\n+    /// assert!(tree.get(&root_id).unwrap().children().contains(&grandchild_id));\n+    /// ```\n+    ///\n+    pub fn swap_sub_tree(&mut self, first_id: &NodeId, second_id: &NodeId) -> Result<(), NodeIdError> {\n+        let (is_valid, error) = self.is_valid_node_id(first_id);\n+        if !is_valid {\n+            return Result::Err(error.expect(\"Tree::swap_sub_tree: Missing an error value on finding an invalid NodeId.\"));\n+        }\n+\n+        let (is_valid, error) = self.is_valid_node_id(second_id);\n+        if !is_valid {\n+            return Result::Err(error.expect(\"Tree::swap_sub_tree: Missing an error value on finding an invalid NodeId.\"));\n+        }\n+\n+        let lower_upper_test = self.find_subtree_root_between_ids(first_id, second_id)\n+        .map(|_| (first_id, second_id))\n+        .or(\n+            self.find_subtree_root_between_ids(second_id, first_id)\n+            .map(|_| (second_id, first_id))\n+        );\n+\n+        if let Some((lower_id, upper_id)) = lower_upper_test\n+        {","path":"src/tree.rs","position":62,"original_position":62,"commit_id":"8de3bcbb1b58daddbcd348641cc22617c4a73ad9","original_commit_id":"8de3bcbb1b58daddbcd348641cc22617c4a73ad9","user":{"login":"iwburns","id":6172641,"avatar_url":"https://avatars.githubusercontent.com/u/6172641?v=3","gravatar_id":"","url":"https://api.github.com/users/iwburns","html_url":"https://github.com/iwburns","followers_url":"https://api.github.com/users/iwburns/followers","following_url":"https://api.github.com/users/iwburns/following{/other_user}","gists_url":"https://api.github.com/users/iwburns/gists{/gist_id}","starred_url":"https://api.github.com/users/iwburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwburns/subscriptions","organizations_url":"https://api.github.com/users/iwburns/orgs","repos_url":"https://api.github.com/users/iwburns/repos","events_url":"https://api.github.com/users/iwburns/events{/privacy}","received_events_url":"https://api.github.com/users/iwburns/received_events","type":"User","site_admin":false},"body":"Could you push `{` up to the previous line here?","created_at":"2016-12-21T21:23:42Z","updated_at":"2016-12-21T21:23:42Z","html_url":"https://github.com/iwburns/id-tree/pull/6#discussion_r93522199","pull_request_url":"https://api.github.com/repos/iwburns/id-tree/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/comments/93522199"},"html":{"href":"https://github.com/iwburns/id-tree/pull/6#discussion_r93522199"},"pull_request":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/iwburns/id-tree/pulls/6","id":98117945,"html_url":"https://github.com/iwburns/id-tree/pull/6","diff_url":"https://github.com/iwburns/id-tree/pull/6.diff","patch_url":"https://github.com/iwburns/id-tree/pull/6.patch","issue_url":"https://api.github.com/repos/iwburns/id-tree/issues/6","number":6,"state":"open","locked":false,"title":"WIP: swap and replace implementation","user":{"login":"Drakulix","id":4404502,"avatar_url":"https://avatars.githubusercontent.com/u/4404502?v=3","gravatar_id":"","url":"https://api.github.com/users/Drakulix","html_url":"https://github.com/Drakulix","followers_url":"https://api.github.com/users/Drakulix/followers","following_url":"https://api.github.com/users/Drakulix/following{/other_user}","gists_url":"https://api.github.com/users/Drakulix/gists{/gist_id}","starred_url":"https://api.github.com/users/Drakulix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Drakulix/subscriptions","organizations_url":"https://api.github.com/users/Drakulix/orgs","repos_url":"https://api.github.com/users/Drakulix/repos","events_url":"https://api.github.com/users/Drakulix/events{/privacy}","received_events_url":"https://api.github.com/users/Drakulix/received_events","type":"User","site_admin":false},"body":"@iwburns  input on the implementation please.\r\nThis time it is especially important, because there is a `TODO` left in the code.\r\n","created_at":"2016-12-15T09:54:46Z","updated_at":"2016-12-21T21:23:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26f8ba6d3459421fbe608927dd46b14f53cc917f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/iwburns/id-tree/pulls/6/commits","review_comments_url":"https://api.github.com/repos/iwburns/id-tree/pulls/6/comments","review_comment_url":"https://api.github.com/repos/iwburns/id-tree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iwburns/id-tree/issues/6/comments","statuses_url":"https://api.github.com/repos/iwburns/id-tree/statuses/8de3bcbb1b58daddbcd348641cc22617c4a73ad9","head":{"label":"Drakulix:feature/swap_replace","ref":"feature/swap_replace","sha":"8de3bcbb1b58daddbcd348641cc22617c4a73ad9","user":{"login":"Drakulix","id":4404502,"avatar_url":"https://avatars.githubusercontent.com/u/4404502?v=3","gravatar_id":"","url":"https://api.github.com/users/Drakulix","html_url":"https://github.com/Drakulix","followers_url":"https://api.github.com/users/Drakulix/followers","following_url":"https://api.github.com/users/Drakulix/following{/other_user}","gists_url":"https://api.github.com/users/Drakulix/gists{/gist_id}","starred_url":"https://api.github.com/users/Drakulix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Drakulix/subscriptions","organizations_url":"https://api.github.com/users/Drakulix/orgs","repos_url":"https://api.github.com/users/Drakulix/repos","events_url":"https://api.github.com/users/Drakulix/events{/privacy}","received_events_url":"https://api.github.com/users/Drakulix/received_events","type":"User","site_admin":false},"repo":{"id":76389632,"name":"id-tree","full_name":"Drakulix/id-tree","owner":{"login":"Drakulix","id":4404502,"avatar_url":"https://avatars.githubusercontent.com/u/4404502?v=3","gravatar_id":"","url":"https://api.github.com/users/Drakulix","html_url":"https://github.com/Drakulix","followers_url":"https://api.github.com/users/Drakulix/followers","following_url":"https://api.github.com/users/Drakulix/following{/other_user}","gists_url":"https://api.github.com/users/Drakulix/gists{/gist_id}","starred_url":"https://api.github.com/users/Drakulix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Drakulix/subscriptions","organizations_url":"https://api.github.com/users/Drakulix/orgs","repos_url":"https://api.github.com/users/Drakulix/repos","events_url":"https://api.github.com/users/Drakulix/events{/privacy}","received_events_url":"https://api.github.com/users/Drakulix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Drakulix/id-tree","description":null,"fork":true,"url":"https://api.github.com/repos/Drakulix/id-tree","forks_url":"https://api.github.com/repos/Drakulix/id-tree/forks","keys_url":"https://api.github.com/repos/Drakulix/id-tree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Drakulix/id-tree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Drakulix/id-tree/teams","hooks_url":"https://api.github.com/repos/Drakulix/id-tree/hooks","issue_events_url":"https://api.github.com/repos/Drakulix/id-tree/issues/events{/number}","events_url":"https://api.github.com/repos/Drakulix/id-tree/events","assignees_url":"https://api.github.com/repos/Drakulix/id-tree/assignees{/user}","branches_url":"https://api.github.com/repos/Drakulix/id-tree/branches{/branch}","tags_url":"https://api.github.com/repos/Drakulix/id-tree/tags","blobs_url":"https://api.github.com/repos/Drakulix/id-tree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Drakulix/id-tree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Drakulix/id-tree/git/refs{/sha}","trees_url":"https://api.github.com/repos/Drakulix/id-tree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Drakulix/id-tree/statuses/{sha}","languages_url":"https://api.github.com/repos/Drakulix/id-tree/languages","stargazers_url":"https://api.github.com/repos/Drakulix/id-tree/stargazers","contributors_url":"https://api.github.com/repos/Drakulix/id-tree/contributors","subscribers_url":"https://api.github.com/repos/Drakulix/id-tree/subscribers","subscription_url":"https://api.github.com/repos/Drakulix/id-tree/subscription","commits_url":"https://api.github.com/repos/Drakulix/id-tree/commits{/sha}","git_commits_url":"https://api.github.com/repos/Drakulix/id-tree/git/commits{/sha}","comments_url":"https://api.github.com/repos/Drakulix/id-tree/comments{/number}","issue_comment_url":"https://api.github.com/repos/Drakulix/id-tree/issues/comments{/number}","contents_url":"https://api.github.com/repos/Drakulix/id-tree/contents/{+path}","compare_url":"https://api.github.com/repos/Drakulix/id-tree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Drakulix/id-tree/merges","archive_url":"https://api.github.com/repos/Drakulix/id-tree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Drakulix/id-tree/downloads","issues_url":"https://api.github.com/repos/Drakulix/id-tree/issues{/number}","pulls_url":"https://api.github.com/repos/Drakulix/id-tree/pulls{/number}","milestones_url":"https://api.github.com/repos/Drakulix/id-tree/milestones{/number}","notifications_url":"https://api.github.com/repos/Drakulix/id-tree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Drakulix/id-tree/labels{/name}","releases_url":"https://api.github.com/repos/Drakulix/id-tree/releases{/id}","deployments_url":"https://api.github.com/repos/Drakulix/id-tree/deployments","created_at":"2016-12-13T19:05:02Z","updated_at":"2016-12-13T19:05:03Z","pushed_at":"2016-12-21T20:58:45Z","git_url":"git://github.com/Drakulix/id-tree.git","ssh_url":"git@github.com:Drakulix/id-tree.git","clone_url":"https://github.com/Drakulix/id-tree.git","svn_url":"https://github.com/Drakulix/id-tree","homepage":null,"size":84,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"iwburns:master","ref":"master","sha":"657c9201ba43ed6bfcc0a2fd633d1323a77e3d71","user":{"login":"iwburns","id":6172641,"avatar_url":"https://avatars.githubusercontent.com/u/6172641?v=3","gravatar_id":"","url":"https://api.github.com/users/iwburns","html_url":"https://github.com/iwburns","followers_url":"https://api.github.com/users/iwburns/followers","following_url":"https://api.github.com/users/iwburns/following{/other_user}","gists_url":"https://api.github.com/users/iwburns/gists{/gist_id}","starred_url":"https://api.github.com/users/iwburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwburns/subscriptions","organizations_url":"https://api.github.com/users/iwburns/orgs","repos_url":"https://api.github.com/users/iwburns/repos","events_url":"https://api.github.com/users/iwburns/events{/privacy}","received_events_url":"https://api.github.com/users/iwburns/received_events","type":"User","site_admin":false},"repo":{"id":68147191,"name":"id-tree","full_name":"iwburns/id-tree","owner":{"login":"iwburns","id":6172641,"avatar_url":"https://avatars.githubusercontent.com/u/6172641?v=3","gravatar_id":"","url":"https://api.github.com/users/iwburns","html_url":"https://github.com/iwburns","followers_url":"https://api.github.com/users/iwburns/followers","following_url":"https://api.github.com/users/iwburns/following{/other_user}","gists_url":"https://api.github.com/users/iwburns/gists{/gist_id}","starred_url":"https://api.github.com/users/iwburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iwburns/subscriptions","organizations_url":"https://api.github.com/users/iwburns/orgs","repos_url":"https://api.github.com/users/iwburns/repos","events_url":"https://api.github.com/users/iwburns/events{/privacy}","received_events_url":"https://api.github.com/users/iwburns/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iwburns/id-tree","description":"A library for creating and modifying Tree structures.","fork":false,"url":"https://api.github.com/repos/iwburns/id-tree","forks_url":"https://api.github.com/repos/iwburns/id-tree/forks","keys_url":"https://api.github.com/repos/iwburns/id-tree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iwburns/id-tree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iwburns/id-tree/teams","hooks_url":"https://api.github.com/repos/iwburns/id-tree/hooks","issue_events_url":"https://api.github.com/repos/iwburns/id-tree/issues/events{/number}","events_url":"https://api.github.com/repos/iwburns/id-tree/events","assignees_url":"https://api.github.com/repos/iwburns/id-tree/assignees{/user}","branches_url":"https://api.github.com/repos/iwburns/id-tree/branches{/branch}","tags_url":"https://api.github.com/repos/iwburns/id-tree/tags","blobs_url":"https://api.github.com/repos/iwburns/id-tree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iwburns/id-tree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iwburns/id-tree/git/refs{/sha}","trees_url":"https://api.github.com/repos/iwburns/id-tree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iwburns/id-tree/statuses/{sha}","languages_url":"https://api.github.com/repos/iwburns/id-tree/languages","stargazers_url":"https://api.github.com/repos/iwburns/id-tree/stargazers","contributors_url":"https://api.github.com/repos/iwburns/id-tree/contributors","subscribers_url":"https://api.github.com/repos/iwburns/id-tree/subscribers","subscription_url":"https://api.github.com/repos/iwburns/id-tree/subscription","commits_url":"https://api.github.com/repos/iwburns/id-tree/commits{/sha}","git_commits_url":"https://api.github.com/repos/iwburns/id-tree/git/commits{/sha}","comments_url":"https://api.github.com/repos/iwburns/id-tree/comments{/number}","issue_comment_url":"https://api.github.com/repos/iwburns/id-tree/issues/comments{/number}","contents_url":"https://api.github.com/repos/iwburns/id-tree/contents/{+path}","compare_url":"https://api.github.com/repos/iwburns/id-tree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iwburns/id-tree/merges","archive_url":"https://api.github.com/repos/iwburns/id-tree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iwburns/id-tree/downloads","issues_url":"https://api.github.com/repos/iwburns/id-tree/issues{/number}","pulls_url":"https://api.github.com/repos/iwburns/id-tree/pulls{/number}","milestones_url":"https://api.github.com/repos/iwburns/id-tree/milestones{/number}","notifications_url":"https://api.github.com/repos/iwburns/id-tree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iwburns/id-tree/labels{/name}","releases_url":"https://api.github.com/repos/iwburns/id-tree/releases{/id}","deployments_url":"https://api.github.com/repos/iwburns/id-tree/deployments","created_at":"2016-09-13T21:00:51Z","updated_at":"2016-12-21T05:29:39Z","pushed_at":"2016-12-21T20:58:47Z","git_url":"git://github.com/iwburns/id-tree.git","ssh_url":"git@github.com:iwburns/id-tree.git","clone_url":"https://github.com/iwburns/id-tree.git","svn_url":"https://github.com/iwburns/id-tree","homepage":"","size":83,"stargazers_count":1,"watchers_count":1,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/6"},"html":{"href":"https://github.com/iwburns/id-tree/pull/6"},"issue":{"href":"https://api.github.com/repos/iwburns/id-tree/issues/6"},"comments":{"href":"https://api.github.com/repos/iwburns/id-tree/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iwburns/id-tree/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/iwburns/id-tree/statuses/8de3bcbb1b58daddbcd348641cc22617c4a73ad9"}}}}
{"actor":{"display_login":"iwburns"}}