|
209 | 209 | //! all the contents of the collection.
|
210 | 210 | //!
|
211 | 211 | //! ```
|
212 |
| -//! let vec = vec![1u, 2, 3, 4]; |
| 212 | +//! let vec = vec![1, 2, 3, 4]; |
213 | 213 | //! for x in vec.iter() {
|
214 | 214 | //! println!("vec contained {}", x);
|
215 | 215 | //! }
|
|
219 | 219 | //! This is great for mutating all the contents of the collection.
|
220 | 220 | //!
|
221 | 221 | //! ```
|
222 |
| -//! let mut vec = vec![1u, 2, 3, 4]; |
| 222 | +//! let mut vec = vec![1, 2, 3, 4]; |
223 | 223 | //! for x in vec.iter_mut() {
|
224 | 224 | //! *x += 1;
|
225 | 225 | //! }
|
|
234 | 234 | //! previous section to do this as efficiently as possible.
|
235 | 235 | //!
|
236 | 236 | //! ```
|
237 |
| -//! let mut vec1 = vec![1u, 2, 3, 4]; |
238 |
| -//! let vec2 = vec![10u, 20, 30, 40]; |
| 237 | +//! let mut vec1 = vec![1, 2, 3, 4]; |
| 238 | +//! let vec2 = vec![10, 20, 30, 40]; |
239 | 239 | //! vec1.extend(vec2.into_iter());
|
240 | 240 | //! ```
|
241 | 241 | //!
|
242 | 242 | //! ```
|
243 | 243 | //! use std::collections::RingBuf;
|
244 | 244 | //!
|
245 |
| -//! let vec = vec![1u, 2, 3, 4]; |
| 245 | +//! let vec = vec![1, 2, 3, 4]; |
246 | 246 | //! let buf: RingBuf<uint> = vec.into_iter().collect();
|
247 | 247 | //! ```
|
248 | 248 | //!
|
|
253 | 253 | //! iterators as the way to iterate over them in reverse order.
|
254 | 254 | //!
|
255 | 255 | //! ```
|
256 |
| -//! let vec = vec![1u, 2, 3, 4]; |
| 256 | +//! let vec = vec![1, 2, 3, 4]; |
257 | 257 | //! for x in vec.iter().rev() {
|
258 | 258 | //! println!("vec contained {}", x);
|
259 | 259 | //! }
|
|
326 | 326 | //! #### Tracking the inebriation of customers at a bar
|
327 | 327 | //!
|
328 | 328 | //! ```
|
329 |
| -//! use std::collections::btree_map::{BTreeMap, Occupied, Vacant}; |
| 329 | +//! use std::collections::btree_map::{BTreeMap, Entry}; |
330 | 330 | //!
|
331 | 331 | //! // A client of the bar. They have an id and a blood alcohol level.
|
332 | 332 | //! struct Person { id: u32, blood_alcohol: f32 };
|
|
341 | 341 | //! // If this is the first time we've seen this customer, initialize them
|
342 | 342 | //! // with no blood alcohol. Otherwise, just retrieve them.
|
343 | 343 | //! let person = match blood_alcohol.entry(id) {
|
344 |
| -//! Vacant(entry) => entry.insert(Person{id: id, blood_alcohol: 0.0}), |
345 |
| -//! Occupied(entry) => entry.into_mut(), |
| 344 | +//! Entry::Vacant(entry) => entry.insert(Person{id: id, blood_alcohol: 0.0}), |
| 345 | +//! Entry::Occupied(entry) => entry.into_mut(), |
346 | 346 | //! };
|
347 | 347 | //!
|
348 | 348 | //! // Reduce their blood alcohol level. It takes time to order and drink a beer!
|
|
0 commit comments