diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-31 14:52:08 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-31 14:52:08 +0100 |
| commit | b0d60a7108bf022f743501b7b2e127fbae695260 (patch) | |
| tree | 1a291325e1405a716f4cf64d91ae6c45bf8cdcf8 /src/test/stdtest | |
| parent | 7080ac15fb13c472985da692ca92c4a48b1f5575 (diff) | |
| download | rust-b0d60a7108bf022f743501b7b2e127fbae695260.tar.gz rust-b0d60a7108bf022f743501b7b2e127fbae695260.zip | |
Add a way to iterate over a str's chars to std::str
Diffstat (limited to 'src/test/stdtest')
| -rw-r--r-- | src/test/stdtest/str.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/stdtest/str.rs b/src/test/stdtest/str.rs index 470c8daee5e..c4923d5d2c3 100644 --- a/src/test/stdtest/str.rs +++ b/src/test/stdtest/str.rs @@ -315,3 +315,16 @@ fn contains() { assert !str::contains("abcde", "def"); assert !str::contains("", "a"); } + +#[test] +fn chars() { + let i = 0; + str::chars("x\u03c0y") {|ch| + alt i { + 0 { assert ch == 'x'; } + 1 { assert ch == '\u03c0'; } + 2 { assert ch == 'y'; } + } + i += 1; + } +} |
