{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/27852","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/27852/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/27852/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/27852/events","html_url":"https://github.com/rust-lang/rust/issues/27852","id":101229490,"number":27852,"title":"Vec::reserve and Vec::reserve_exact examples should be differentiated ","user":{"login":"frewsxcv","id":416575,"avatar_url":"https://avatars.githubusercontent.com/u/416575?v=3","gravatar_id":"","url":"https://api.github.com/users/frewsxcv","html_url":"https://github.com/frewsxcv","followers_url":"https://api.github.com/users/frewsxcv/followers","following_url":"https://api.github.com/users/frewsxcv/following{/other_user}","gists_url":"https://api.github.com/users/frewsxcv/gists{/gist_id}","starred_url":"https://api.github.com/users/frewsxcv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frewsxcv/subscriptions","organizations_url":"https://api.github.com/users/frewsxcv/orgs","repos_url":"https://api.github.com/users/frewsxcv/repos","events_url":"https://api.github.com/users/frewsxcv/events{/privacy}","received_events_url":"https://api.github.com/users/frewsxcv/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-docs","name":"A-docs","color":"d7e102"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-16T03:18:31Z","updated_at":"2015-08-18T15:21:43Z","closed_at":"2015-08-18T15:21:43Z","body":"`Vec::reserve` and `Vec::reserve_exact` are two different methods that do slightly different things\r\n\r\n* https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.reserve\r\n* https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.reserve_exact\r\n\r\nRight now, both of their examples are virtually identical.\r\n\r\n```rust\r\nlet mut vec = vec![1];\r\nvec.reserve(10);\r\nassert!(vec.capacity() >= 11);\r\n```\r\n\r\n```rust\r\nlet mut vec = vec![1];\r\nvec.reserve_exact(10);\r\nassert!(vec.capacity() >= 11);\r\n```\r\n\r\nConsidering these two methods have different behavior, ideally the examples would demonstrate more clearly how they differ. That said, I haven't though of anything good yet, but I thought I might as well open this. If the differences are too subtle to demonstrate in an example, this can be closed."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/132248441","html_url":"https://github.com/rust-lang/rust/issues/27852#issuecomment-132248441","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/27852","id":132248441,"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},"created_at":"2015-08-18T15:21:43Z","updated_at":"2015-08-18T15:21:43Z","body":"The hard part about writing an example for this is that what they affect isn't something you can see directly: the amount of memory that may or may not get allocated. `reserve` _might_ do the same thing, but also might not, and is deliberately under-specified so that different allocators can choose what to do.\r\n\r\n I'm also open to improving any example, but without a concrete suggestion, I don't think we can move forward here. If you (or anyone finding this ticket later) can think of something, please leave a note and I'll re-open!"}}