{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/26431361","id":26431361,"diff_hunk":"@@ -246,6 +247,56 @@ struct IndexItem {\n     path: String,\n     desc: String,\n     parent: Option<ast::DefId>,\n+    search_type: Option<IndexItemFunctionType>,\n+}\n+\n+/// A type used for the search index.\n+struct Type {\n+    name: Option<String>,\n+}\n+\n+impl fmt::Display for Type {\n+    /// Formats type as {name: $name}.\n+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n+        try!(write!(f, \"{{\"));\n+        // Wrapping struct fmt should never call us when self.name is None,\n+        // but just to be safe we write `null` in that case.\n+        try!(write!(f, \"\\\"name\\\":\\\"{}\\\"\", self.name.as_ref().unwrap_or(&\"null\".to_string())));","path":"src/librustdoc/html/render.rs","position":26,"original_position":26,"commit_id":"c2a112b7362e065f963de298313489644f130639","original_commit_id":"c2a112b7362e065f963de298313489644f130639","user":{"login":"mihneadb","id":643127,"avatar_url":"https://avatars.githubusercontent.com/u/643127?v=3","gravatar_id":"","url":"https://api.github.com/users/mihneadb","html_url":"https://github.com/mihneadb","followers_url":"https://api.github.com/users/mihneadb/followers","following_url":"https://api.github.com/users/mihneadb/following{/other_user}","gists_url":"https://api.github.com/users/mihneadb/gists{/gist_id}","starred_url":"https://api.github.com/users/mihneadb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihneadb/subscriptions","organizations_url":"https://api.github.com/users/mihneadb/orgs","repos_url":"https://api.github.com/users/mihneadb/repos","events_url":"https://api.github.com/users/mihneadb/events{/privacy}","received_events_url":"https://api.github.com/users/mihneadb/received_events","type":"User","site_admin":false},"body":"Whoops!","created_at":"2015-03-13T23:54:23Z","updated_at":"2015-03-13T23:54:23Z","html_url":"https://github.com/rust-lang/rust/pull/23289#discussion_r26431361","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/23289","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/26431361"},"html":{"href":"https://github.com/rust-lang/rust/pull/23289#discussion_r26431361"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/23289"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/23289","id":30989533,"html_url":"https://github.com/rust-lang/rust/pull/23289","diff_url":"https://github.com/rust-lang/rust/pull/23289.diff","patch_url":"https://github.com/rust-lang/rust/pull/23289.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/23289","number":23289,"state":"open","locked":false,"title":"Rustdoc search by type","user":{"login":"mihneadb","id":643127,"avatar_url":"https://avatars.githubusercontent.com/u/643127?v=3","gravatar_id":"","url":"https://api.github.com/users/mihneadb","html_url":"https://github.com/mihneadb","followers_url":"https://api.github.com/users/mihneadb/followers","following_url":"https://api.github.com/users/mihneadb/following{/other_user}","gists_url":"https://api.github.com/users/mihneadb/gists{/gist_id}","starred_url":"https://api.github.com/users/mihneadb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihneadb/subscriptions","organizations_url":"https://api.github.com/users/mihneadb/orgs","repos_url":"https://api.github.com/users/mihneadb/repos","events_url":"https://api.github.com/users/mihneadb/events{/privacy}","received_events_url":"https://api.github.com/users/mihneadb/received_events","type":"User","site_admin":false},"body":"This adds search by type (for functions/methods) support to Rustdoc. Target issue is at https://github.com/rust-lang/rfcs/issues/658.\r\n\r\nI've described my approach here: https://github.com/rust-lang/rfcs/issues/658#issuecomment-76484200. I'll copy the text in here as well:\r\n\r\n---\r\n\r\nHi, it took me longer than I wished, but I have implemented this in a not-too-complex way that I think can be extended to support more complex features (like the ones mentioned [here](https://github.com/rust-lang/rust/issues/12866#issuecomment-66945317)).\r\n\r\nThe idea is to generate a JSON representation of the types of methods/functions in the existing index, and then make the JS understand when it should look by type (and not by name).\r\n\r\nI tried to come up with a JSON representation that can be extended to support generics, bounds, ref/mut annotations and so on. Here are a few samples:\r\n\r\nFunction:\r\n\r\n```rust\r\nfn to_uppercase(c: char) -> char\r\n```\r\n\r\n```json\r\n{\r\n    \"inputs\": [\r\n        {\"name\": \"char\"}\r\n    ],\r\n    \"output\": {\r\n        \"name\": \"char\",\r\n    }\r\n}\r\n```\r\n\r\nMethod (implemented or defined in trait):\r\n\r\n```rust\r\n// in struct Vec\r\n// self is considered an argument as well\r\nfn capacity(&self) -> usize\r\n```\r\n\r\n```json\r\n{\r\n    \"inputs\": [\r\n        {\"name\": \"vec\"}\r\n    ],\r\n    \"output\": {\r\n        \"name\": \"usize\"\r\n    }\r\n}\r\n```\r\n\r\nThis simple format can be extended by adding more fields, like `generic: bool`, a `bounds` mapping and so on.\r\n\r\nI have a working implementation in https://github.com/rust-lang/rust/compare/master...mihneadb:rustdoc-search-by-type. You can check out a live demo [here](http://data.mihneadb.net/doc/std/index.html?search=charext%20-%3E%20char).\r\n\r\n![screenshot from 2015-02-28 00 54 00](https://cloud.githubusercontent.com/assets/643127/6422722/7e5374ee-bee4-11e4-99a6-9aac3c9d5068.png)\r\n\r\n\r\nThe feature list is not that long:\r\n- search by types (you *can* use generics as well, as long as you use the exact name - e.g. [`vec,t -> `](http://data.mihneadb.net/doc/std/index.html?search=vec%2C%20t%20-%3E))\r\n- order of arguments does not matter\r\n- `self` is took into account as well (e.g. search for `vec -> usize`)\r\n- does not use \"complex\" annotations (e.g. you don't search for `&char -> char` but for `char -> char`)\r\n\r\nMy goal is to get a working, minimal \"base\" merged so that others can build upon it. How should I proceed? Do I open a PR (badly in need of code review since this is my first non \"hello world\"-ish rust code)?\r\n\r\n---\r\n","created_at":"2015-03-11T21:57:57Z","updated_at":"2015-03-13T23:54:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85300b7bc95ff9292f830bdaeee23af9388a6538","assignee":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/23289/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/23289/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/23289/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/c2a112b7362e065f963de298313489644f130639","head":{"label":"mihneadb:rustdoc-search-by-type","ref":"rustdoc-search-by-type","sha":"c2a112b7362e065f963de298313489644f130639","user":{"login":"mihneadb","id":643127,"avatar_url":"https://avatars.githubusercontent.com/u/643127?v=3","gravatar_id":"","url":"https://api.github.com/users/mihneadb","html_url":"https://github.com/mihneadb","followers_url":"https://api.github.com/users/mihneadb/followers","following_url":"https://api.github.com/users/mihneadb/following{/other_user}","gists_url":"https://api.github.com/users/mihneadb/gists{/gist_id}","starred_url":"https://api.github.com/users/mihneadb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihneadb/subscriptions","organizations_url":"https://api.github.com/users/mihneadb/orgs","repos_url":"https://api.github.com/users/mihneadb/repos","events_url":"https://api.github.com/users/mihneadb/events{/privacy}","received_events_url":"https://api.github.com/users/mihneadb/received_events","type":"User","site_admin":false},"repo":{"id":11911232,"name":"rust","full_name":"mihneadb/rust","owner":{"login":"mihneadb","id":643127,"avatar_url":"https://avatars.githubusercontent.com/u/643127?v=3","gravatar_id":"","url":"https://api.github.com/users/mihneadb","html_url":"https://github.com/mihneadb","followers_url":"https://api.github.com/users/mihneadb/followers","following_url":"https://api.github.com/users/mihneadb/following{/other_user}","gists_url":"https://api.github.com/users/mihneadb/gists{/gist_id}","starred_url":"https://api.github.com/users/mihneadb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihneadb/subscriptions","organizations_url":"https://api.github.com/users/mihneadb/orgs","repos_url":"https://api.github.com/users/mihneadb/repos","events_url":"https://api.github.com/users/mihneadb/events{/privacy}","received_events_url":"https://api.github.com/users/mihneadb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mihneadb/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/mihneadb/rust","forks_url":"https://api.github.com/repos/mihneadb/rust/forks","keys_url":"https://api.github.com/repos/mihneadb/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mihneadb/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mihneadb/rust/teams","hooks_url":"https://api.github.com/repos/mihneadb/rust/hooks","issue_events_url":"https://api.github.com/repos/mihneadb/rust/issues/events{/number}","events_url":"https://api.github.com/repos/mihneadb/rust/events","assignees_url":"https://api.github.com/repos/mihneadb/rust/assignees{/user}","branches_url":"https://api.github.com/repos/mihneadb/rust/branches{/branch}","tags_url":"https://api.github.com/repos/mihneadb/rust/tags","blobs_url":"https://api.github.com/repos/mihneadb/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mihneadb/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mihneadb/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/mihneadb/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mihneadb/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/mihneadb/rust/languages","stargazers_url":"https://api.github.com/repos/mihneadb/rust/stargazers","contributors_url":"https://api.github.com/repos/mihneadb/rust/contributors","subscribers_url":"https://api.github.com/repos/mihneadb/rust/subscribers","subscription_url":"https://api.github.com/repos/mihneadb/rust/subscription","commits_url":"https://api.github.com/repos/mihneadb/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/mihneadb/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/mihneadb/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/mihneadb/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/mihneadb/rust/contents/{+path}","compare_url":"https://api.github.com/repos/mihneadb/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mihneadb/rust/merges","archive_url":"https://api.github.com/repos/mihneadb/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mihneadb/rust/downloads","issues_url":"https://api.github.com/repos/mihneadb/rust/issues{/number}","pulls_url":"https://api.github.com/repos/mihneadb/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/mihneadb/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/mihneadb/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mihneadb/rust/labels{/name}","releases_url":"https://api.github.com/repos/mihneadb/rust/releases{/id}","created_at":"2013-08-05T23:27:55Z","updated_at":"2015-02-20T16:45:54Z","pushed_at":"2015-03-13T22:49:08Z","git_url":"git://github.com/mihneadb/rust.git","ssh_url":"git@github.com:mihneadb/rust.git","clone_url":"https://github.com/mihneadb/rust.git","svn_url":"https://github.com/mihneadb/rust","homepage":"http://www.rust-lang.org","size":242270,"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":"rust-lang:master","ref":"master","sha":"f899513a30165946a75ff7f515ab37a226e72172","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"a safe, concurrent, practical language","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","created_at":"2010-06-16T20:39:03Z","updated_at":"2015-03-13T22:51:07Z","pushed_at":"2015-03-13T22:51:09Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"http://www.rust-lang.org","size":505750,"stargazers_count":9723,"watchers_count":9723,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1888,"mirror_url":null,"open_issues_count":2031,"forks":1888,"open_issues":2031,"watchers":9723,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/23289"},"html":{"href":"https://github.com/rust-lang/rust/pull/23289"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/23289"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/23289/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/23289/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/23289/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/c2a112b7362e065f963de298313489644f130639"}}}}