@@ -45,66 +45,72 @@ import is_XID_start = unicode::derived_property::XID_Start;
45
45
import is_XID_continue = unicode:: derived_property:: XID_Continue ;
46
46
47
47
48
- #[ doc(
49
- brief = " Indicates whether a character is in lower case, defined \
50
- in terms of the Unicode General Category 'Ll'."
51
- ) ]
48
+ #[ doc = "
49
+ Indicates whether a character is in lower case, defined
50
+ in terms of the Unicode General Category 'Ll'
51
+ " ]
52
52
pure fn is_lowercase ( c : char ) -> bool {
53
53
ret unicode:: general_category:: Ll ( c) ;
54
54
}
55
55
56
- #[ doc(
57
- brief = " Indicates whether a character is in upper case, defined \
58
- in terms of the Unicode General Category 'Lu'."
59
- ) ]
56
+ #[ doc = "
57
+ Indicates whether a character is in upper case, defined
58
+ in terms of the Unicode General Category 'Lu'.
59
+ " ]
60
60
pure fn is_uppercase ( c : char ) -> bool {
61
61
ret unicode:: general_category:: Lu ( c) ;
62
62
}
63
63
64
- #[ doc(
65
- brief = " Indicates whether a character is whitespace, defined in \
66
- terms of the Unicode General Categories 'Zs', 'Zl', 'Zp' \
67
- additional 'Cc'-category control codes in the range [0x09, 0x0d]"
68
- ) ]
64
+ #[ doc = "
65
+ Indicates whether a character is whitespace, defined in
66
+ terms of the Unicode General Categories 'Zs', 'Zl', 'Zp'
67
+ additional 'Cc'-category control codes in the range [0x09, 0x0d]
68
+ " ]
69
69
pure fn is_whitespace ( c : char ) -> bool {
70
70
ret ( '\x09' <= c && c <= '\x0d' )
71
71
|| unicode:: general_category:: Zs ( c)
72
72
|| unicode:: general_category:: Zl ( c)
73
73
|| unicode:: general_category:: Zp ( c) ;
74
74
}
75
75
76
- #[ doc(
77
- brief = " Indicates whether a character is alphanumeric, defined \
78
- in terms of the Unicode General Categories 'Nd', \
79
- 'Nl', 'No' and the Derived Core Property 'Alphabetic'."
80
- ) ]
76
+ #[ doc = "
77
+ Indicates whether a character is alphanumeric, defined
78
+ in terms of the Unicode General Categories 'Nd',
79
+ 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
80
+ " ]
81
81
pure fn is_alphanumeric ( c : char ) -> bool {
82
82
ret unicode:: derived_property:: Alphabetic ( c) ||
83
83
unicode:: general_category:: Nd ( c) ||
84
84
unicode:: general_category:: Nl ( c) ||
85
85
unicode:: general_category:: No ( c) ;
86
86
}
87
87
88
- #[ doc( brief = "Indicates whether the character is an ASCII character" ) ]
88
+ #[ doc = "Indicates whether the character is an ASCII character" ]
89
89
pure fn is_ascii ( c : char ) -> bool {
90
90
c - ( '\x7F' & c) == '\x00'
91
91
}
92
92
93
- #[ doc( brief = "Indicates whether the character is numeric (Nd, Nl, or No)" ) ]
93
+ #[ doc = "Indicates whether the character is numeric (Nd, Nl, or No)" ]
94
94
pure fn is_digit ( c : char ) -> bool {
95
95
ret unicode:: general_category:: Nd ( c) ||
96
96
unicode:: general_category:: Nl ( c) ||
97
97
unicode:: general_category:: No ( c) ;
98
98
}
99
99
100
- #[ doc(
101
- brief = "Convert a char to the corresponding digit. \
102
- Safety note: This function fails if `c` is not a valid char",
103
- return = "If `c` is between '0' and '9', the corresponding value \
104
- between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is \
105
- 'b' or 'B', 11, etc. Returns none if the char does not \
106
- refer to a digit in the given radix."
107
- ) ]
100
+ #[ doc = "
101
+ Convert a char to the corresponding digit.
102
+
103
+ # Safety note
104
+
105
+ This function fails if `c` is not a valid char
106
+
107
+ # Return value
108
+
109
+ If `c` is between '0' and '9', the corresponding value
110
+ between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is
111
+ 'b' or 'B', 11, etc. Returns none if the char does not
112
+ refer to a digit in the given radix.
113
+ " ]
108
114
pure fn to_digit ( c : char , radix : uint ) -> option < uint > {
109
115
let val = alt c {
110
116
'0' to ' 9 ' { c as uint - ( '0' as uint ) }
@@ -119,9 +125,7 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> {
119
125
/*
120
126
FIXME: works only on ASCII
121
127
*/
122
- #[ doc(
123
- brief = "Convert a char to the corresponding lower case."
124
- ) ]
128
+ #[ doc = "Convert a char to the corresponding lower case." ]
125
129
pure fn to_lower ( c : char ) -> char {
126
130
alt c {
127
131
'A' to ' Z ' { ( ( c as u8 ) + 32u8 ) as char }
@@ -132,20 +136,21 @@ pure fn to_lower(c: char) -> char {
132
136
/*
133
137
FIXME: works only on ASCII
134
138
*/
135
- #[ doc(
136
- brief = "Convert a char to the corresponding upper case."
137
- ) ]
139
+ #[ doc = "Convert a char to the corresponding upper case." ]
138
140
pure fn to_upper ( c : char ) -> char {
139
141
alt c {
140
142
'a' to ' z' { ( ( c as u8 ) - 32u8 ) as char }
141
143
_ { c }
142
144
}
143
145
}
144
146
145
- #[ doc(
146
- brief = "Compare two chars." ,
147
- return = "-1 if a<b, 0 if a==b, +1 if a>b"
148
- ) ]
147
+ #[ doc = "
148
+ Compare two chars
149
+
150
+ # Return value
151
+
152
+ -1 if a < b, 0 if a == b, +1 if a > b
153
+ " ]
149
154
pure fn cmp ( a : char , b : char ) -> int {
150
155
ret if b > a { -1 }
151
156
else if b < a { 1 }
0 commit comments