1 module dkh.ascii;
2 
3 /**
4 ASCII-Only String
5  */
6 struct ASCIIString {
7     string s;
8     alias s this;
9     this(string s) {
10         this.s = s;
11     }
12     ref immutable(char) front() const { return s[0]; } ///
13     ref immutable(char) back() const { return s[$-1]; } ///
14     void popFront() { s = s[1..$]; } ///
15     void popBack() { s = s[0..$-1]; } ///
16 }
17 
18 ///
19 unittest {
20     import std.algorithm;
21     import std.range.primitives;
22     auto s = "タネなし手品";
23     auto asc = s.ASCIIString;
24     assert(s.front == 'タ');
25     assert(asc.front == "タ"[0]);
26     assert(s.back == '品');
27     assert(asc.back == "品"[$-1]);
28 }