{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/book/pulls/comments/71785919","id":71785919,"diff_hunk":"@@ -0,0 +1,308 @@\n+# Vectors\n+\n+The first type we'll look at is `Vec<T>`, also known as a 'vector'. Vectors\n+allow you to store more than one value in a single data structure next to each\n+other in memory.\n+\n+## Creating a new vector\n+\n+To create a new vector, you can call the `new` function:\n+\n+```rust\n+let v: Vec<i32> = Vec::new();\n+```\n+\n+You'll note that we added a type annotation here. Because we don't actually do\n+anything with the vector, Rust doesn't know what kind of elements we intend to\n+store. This is an important point. Vectors are homogenous: they may store many\n+values, but those values must all be the same type. Vectors are generic over\n+the type you store inside them, and the angle brackets here tell Rust that\n+this vector will hold elements of the `i32` type.\n+\n+That said, in real code, you very rarely need to do this type annotation. Let's\n+insert some values to see this in action. To put elements in the vector, we can\n+use the `push` method:\n+\n+```rust\n+let mut v = Vec::new();\n+\n+v.push(5);\n+v.push(6);\n+v.push(7);\n+v.push(8);\n+```\n+\n+Since these numbers are `i32`s, Rust can infer the type of the vector, so we","path":"src/ch09-02-vectors.md","position":35,"original_position":35,"commit_id":"17b237f38c7e3c733341d6749df5ca743025ecf4","original_commit_id":"17b237f38c7e3c733341d6749df5ca743025ecf4","user":{"login":"jonathandturner","id":547158,"avatar_url":"https://avatars.githubusercontent.com/u/547158?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathandturner","html_url":"https://github.com/jonathandturner","followers_url":"https://api.github.com/users/jonathandturner/followers","following_url":"https://api.github.com/users/jonathandturner/following{/other_user}","gists_url":"https://api.github.com/users/jonathandturner/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathandturner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathandturner/subscriptions","organizations_url":"https://api.github.com/users/jonathandturner/orgs","repos_url":"https://api.github.com/users/jonathandturner/repos","events_url":"https://api.github.com/users/jonathandturner/events{/privacy}","received_events_url":"https://api.github.com/users/jonathandturner/received_events","type":"User","site_admin":false},"body":"Are they always i32 for simple numbers?","created_at":"2016-07-21T20:58:30Z","updated_at":"2016-07-21T20:58:30Z","html_url":"https://github.com/rust-lang/book/pull/137#discussion_r71785919","pull_request_url":"https://api.github.com/repos/rust-lang/book/pulls/137","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/book/pulls/comments/71785919"},"html":{"href":"https://github.com/rust-lang/book/pull/137#discussion_r71785919"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/book/pulls/137"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/book/pulls/137","id":78057424,"html_url":"https://github.com/rust-lang/book/pull/137","diff_url":"https://github.com/rust-lang/book/pull/137.diff","patch_url":"https://github.com/rust-lang/book/pull/137.patch","issue_url":"https://api.github.com/repos/rust-lang/book/issues/137","number":137,"state":"open","locked":false,"title":"some work on collections","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},"body":"I started fleshing out some stuff about data structures. I feel pretty good about this, with some caveats discussed below.\r\n\r\nAlso, I would really like to hear what @carols10cents, @aturon, and @jonathandturner (think about showing the internal representation of `Vec` like this; we haven't seen raw pointers, but I really like the idea of giving people an understanding at this level. I'm not sure if this pacing is correct, like, maybe the details of how `insert()` works should go at the end, rather than in the middle?\r\n\r\nThere are two ways this PR needs more work, beyond all that:\r\n\r\n1. I feel like I should put more examples in Vec, but wanted to give you an idea of the style I'm shooting for here before worrrying too much about exactly what should be included. Thoughts welcome! For one, I was thinking about showing off enums in vectors as a way of storing multiple types of elements...\r\n2. I fleshed out very very roughly what I'd want to cover for the other chapters as well, It's basically \"show off CRUD\", though I want to consider just dropping \"delete\" to be a reminder sentence to the vector version, rather than re-explaining Drop each time. Plus, each one has their own little tweaks: hashmap has entry, string will have the utf-8 stuff.","created_at":"2016-07-19T22:04:15Z","updated_at":"2016-07-21T20:58:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83d1fda5b90e9cd749949d8989d4ad76860bfdd6","assignee":{"login":"carols10cents","id":193874,"avatar_url":"https://avatars.githubusercontent.com/u/193874?v=3","gravatar_id":"","url":"https://api.github.com/users/carols10cents","html_url":"https://github.com/carols10cents","followers_url":"https://api.github.com/users/carols10cents/followers","following_url":"https://api.github.com/users/carols10cents/following{/other_user}","gists_url":"https://api.github.com/users/carols10cents/gists{/gist_id}","starred_url":"https://api.github.com/users/carols10cents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carols10cents/subscriptions","organizations_url":"https://api.github.com/users/carols10cents/orgs","repos_url":"https://api.github.com/users/carols10cents/repos","events_url":"https://api.github.com/users/carols10cents/events{/privacy}","received_events_url":"https://api.github.com/users/carols10cents/received_events","type":"User","site_admin":false},"assignees":[{"login":"carols10cents","id":193874,"avatar_url":"https://avatars.githubusercontent.com/u/193874?v=3","gravatar_id":"","url":"https://api.github.com/users/carols10cents","html_url":"https://github.com/carols10cents","followers_url":"https://api.github.com/users/carols10cents/followers","following_url":"https://api.github.com/users/carols10cents/following{/other_user}","gists_url":"https://api.github.com/users/carols10cents/gists{/gist_id}","starred_url":"https://api.github.com/users/carols10cents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carols10cents/subscriptions","organizations_url":"https://api.github.com/users/carols10cents/orgs","repos_url":"https://api.github.com/users/carols10cents/repos","events_url":"https://api.github.com/users/carols10cents/events{/privacy}","received_events_url":"https://api.github.com/users/carols10cents/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/book/pulls/137/commits","review_comments_url":"https://api.github.com/repos/rust-lang/book/pulls/137/comments","review_comment_url":"https://api.github.com/repos/rust-lang/book/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/book/issues/137/comments","statuses_url":"https://api.github.com/repos/rust-lang/book/statuses/17b237f38c7e3c733341d6749df5ca743025ecf4","head":{"label":"rust-lang:data-structures","ref":"data-structures","sha":"17b237f38c7e3c733341d6749df5ca743025ecf4","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":47854924,"name":"book","full_name":"rust-lang/book","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/book","description":"The Rust Programming Language","fork":false,"url":"https://api.github.com/repos/rust-lang/book","forks_url":"https://api.github.com/repos/rust-lang/book/forks","keys_url":"https://api.github.com/repos/rust-lang/book/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/book/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/book/teams","hooks_url":"https://api.github.com/repos/rust-lang/book/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/book/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/book/events","assignees_url":"https://api.github.com/repos/rust-lang/book/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/book/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/book/tags","blobs_url":"https://api.github.com/repos/rust-lang/book/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/book/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/book/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/book/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/book/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/book/languages","stargazers_url":"https://api.github.com/repos/rust-lang/book/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/book/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/book/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/book/subscription","commits_url":"https://api.github.com/repos/rust-lang/book/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/book/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/book/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/book/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/book/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/book/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/book/merges","archive_url":"https://api.github.com/repos/rust-lang/book/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/book/downloads","issues_url":"https://api.github.com/repos/rust-lang/book/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/book/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/book/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/book/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/book/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/book/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/book/deployments","created_at":"2015-12-11T22:49:49Z","updated_at":"2016-07-20T17:00:44Z","pushed_at":"2016-07-21T20:50:36Z","git_url":"git://github.com/rust-lang/book.git","ssh_url":"git@github.com:rust-lang/book.git","clone_url":"https://github.com/rust-lang/book.git","svn_url":"https://github.com/rust-lang/book","homepage":"http://rust-lang.github.io/book/","size":2495,"stargazers_count":186,"watchers_count":186,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":47,"mirror_url":null,"open_issues_count":35,"forks":47,"open_issues":35,"watchers":186,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"463c53597ca953153ba9bf90b0570f0f12661e10","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":47854924,"name":"book","full_name":"rust-lang/book","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/book","description":"The Rust Programming Language","fork":false,"url":"https://api.github.com/repos/rust-lang/book","forks_url":"https://api.github.com/repos/rust-lang/book/forks","keys_url":"https://api.github.com/repos/rust-lang/book/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/book/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/book/teams","hooks_url":"https://api.github.com/repos/rust-lang/book/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/book/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/book/events","assignees_url":"https://api.github.com/repos/rust-lang/book/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/book/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/book/tags","blobs_url":"https://api.github.com/repos/rust-lang/book/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/book/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/book/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/book/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/book/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/book/languages","stargazers_url":"https://api.github.com/repos/rust-lang/book/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/book/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/book/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/book/subscription","commits_url":"https://api.github.com/repos/rust-lang/book/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/book/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/book/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/book/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/book/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/book/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/book/merges","archive_url":"https://api.github.com/repos/rust-lang/book/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/book/downloads","issues_url":"https://api.github.com/repos/rust-lang/book/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/book/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/book/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/book/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/book/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/book/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/book/deployments","created_at":"2015-12-11T22:49:49Z","updated_at":"2016-07-20T17:00:44Z","pushed_at":"2016-07-21T20:50:36Z","git_url":"git://github.com/rust-lang/book.git","ssh_url":"git@github.com:rust-lang/book.git","clone_url":"https://github.com/rust-lang/book.git","svn_url":"https://github.com/rust-lang/book","homepage":"http://rust-lang.github.io/book/","size":2495,"stargazers_count":186,"watchers_count":186,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":47,"mirror_url":null,"open_issues_count":35,"forks":47,"open_issues":35,"watchers":186,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/book/pulls/137"},"html":{"href":"https://github.com/rust-lang/book/pull/137"},"issue":{"href":"https://api.github.com/repos/rust-lang/book/issues/137"},"comments":{"href":"https://api.github.com/repos/rust-lang/book/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/book/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/book/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/book/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/book/statuses/17b237f38c7e3c733341d6749df5ca743025ecf4"}}}}
{"actor":{"display_login":"jonathandturner"}}