From b0d60a7108bf022f743501b7b2e127fbae695260 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 31 Oct 2011 14:52:08 +0100 Subject: Add a way to iterate over a str's chars to std::str --- src/test/stdtest/str.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/test/stdtest') 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; + } +} -- cgit 1.4.1-3-g733a5