You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Certain features (`step_by()` and inclusive range) require `nightly` compiler. If you are on `stable`, in order to compile the examples, you have to comment out relevant code sections.
18
20
19
21
## Contents
22
+
20
23
-[Introduction](#introduction)
21
24
-[Basic Ranges](#basic-ranges)
22
25
-[Digging Deeper](#digging-deeper)
@@ -236,9 +239,9 @@ Programs that manipulate strings or text often require the ability to iterate ov
236
239
237
240
To use the `char_iter`, put the following in your `Cargo.toml`
238
241
239
-
```
242
+
```toml
240
243
[dependencies]
241
-
char-iter = "*"
244
+
char-iter = "0.1"
242
245
```
243
246
244
247
And then generate a character range with `char_iter::new()` method:
@@ -346,9 +349,9 @@ The [itertools crate](http://bluss.github.io/rust-itertools/doc/itertools/trait.
346
349
347
350
To use `itertools`, add the following to your `Cargo.toml`:
348
351
349
-
```
352
+
```toml
350
353
[dependencies]
351
-
itertools = "*"
354
+
itertools = "0.4"
352
355
```
353
356
354
357
The `unique()` adaptor eliminates duplicates from an iterator. The duplicates do not need to be sequential.
@@ -365,7 +368,7 @@ for d in unique {
365
368
}
366
369
367
370
//output: 1 4 3 2 5
368
-
```
371
+
```
369
372
370
373
The `join()` adaptor combines iterator elements into a single string with a separator in between the elements.
371
374
@@ -378,7 +381,7 @@ let list = creatures.iter().join(", ");
378
381
println!("In the enchanted forest, we found {}.", list);
379
382
380
383
// output: In the enchanted forest, we found banshee, basilisk, centaur.
381
-
```
384
+
```
382
385
383
386
The `sorted_by()` adaptor applies custom sorting order to iterator elements, returning a sorted vector. The following program will print out top 5 happiest countries, according to 2016 World Happiness Index.
384
387
@@ -409,7 +412,6 @@ for (country, rating) in top_contries {
0 commit comments