@@ -277,20 +277,20 @@ mod rt {
277
277
278
278
type conv = {flags: u32, width: count, precision: count, ty: ty};
279
279
280
- fn conv_int(cv: conv, i: int) -> ~str {
280
+ pure fn conv_int(cv: conv, i: int) -> ~str {
281
281
let radix = 10u;
282
282
let prec = get_int_precision(cv);
283
283
let mut s : ~str = int_to_str_prec(i, radix, prec);
284
284
if 0 <= i {
285
285
if have_flag(cv.flags, flag_sign_always) {
286
- str::unshift_char(s, '+');
286
+ unchecked { str::unshift_char(s, '+') } ;
287
287
} else if have_flag(cv.flags, flag_space_for_sign) {
288
- str::unshift_char(s, ' ');
288
+ unchecked { str::unshift_char(s, ' ') } ;
289
289
}
290
290
}
291
- ret pad(cv, s, pad_signed);
291
+ ret unchecked { pad(cv, s, pad_signed) } ;
292
292
}
293
- fn conv_uint(cv: conv, u: uint) -> ~str {
293
+ pure fn conv_uint(cv: conv, u: uint) -> ~str {
294
294
let prec = get_int_precision(cv);
295
295
let mut rs =
296
296
alt cv.ty {
@@ -300,17 +300,17 @@ mod rt {
300
300
ty_bits { uint_to_str_prec(u, 2u, prec) }
301
301
ty_octal { uint_to_str_prec(u, 8u, prec) }
302
302
};
303
- ret pad(cv, rs, pad_unsigned);
303
+ ret unchecked { pad(cv, rs, pad_unsigned) } ;
304
304
}
305
- fn conv_bool(cv: conv, b: bool) -> ~str {
305
+ pure fn conv_bool(cv: conv, b: bool) -> ~str {
306
306
let s = if b { ~" true" } else { ~"false" } ;
307
307
// run the boolean conversion through the string conversion logic,
308
308
// giving it the same rules for precision, etc.
309
309
ret conv_str( cv, s) ;
310
310
}
311
- fn conv_char ( cv : conv , c : char ) -> ~str {
311
+ pure fn conv_char ( cv : conv , c : char ) -> ~str {
312
312
let mut s = str:: from_char ( c) ;
313
- ret pad( cv, s, pad_nozero) ;
313
+ ret unchecked { pad( cv, s, pad_nozero) } ;
314
314
}
315
315
pure fn conv_str ( cv : conv , s : & str ) -> ~str {
316
316
// For strings, precision is the maximum characters
@@ -325,29 +325,29 @@ mod rt {
325
325
} ;
326
326
ret unchecked { pad( cv, unpadded, pad_nozero) } ;
327
327
}
328
- fn conv_float ( cv : conv , f : float ) -> ~str {
328
+ pure fn conv_float ( cv : conv , f : float ) -> ~str {
329
329
let ( to_str, digits) = alt cv. precision {
330
330
count_is ( c) { ( float:: to_str_exact, c as uint ) }
331
331
count_implied { ( float:: to_str, 6 u) }
332
332
} ;
333
- let mut s = to_str ( f, digits) ;
333
+ let mut s = unchecked { to_str( f, digits) } ;
334
334
if 0.0 <= f {
335
335
if have_flag ( cv. flags , flag_sign_always) {
336
336
s = ~"+" + s;
337
337
} else if have_flag(cv.flags, flag_space_for_sign) {
338
338
s = ~" " + s;
339
339
}
340
340
}
341
- ret pad(cv, s, pad_float);
341
+ ret unchecked { pad(cv, s, pad_float) } ;
342
342
}
343
- fn conv_poly<T>(cv: conv, v: T) -> ~str {
343
+ pure fn conv_poly<T>(cv: conv, v: T) -> ~str {
344
344
let s = sys::log_str(v);
345
345
ret conv_str(cv, s);
346
346
}
347
347
348
348
// Convert an int to string with minimum number of digits. If precision is
349
349
// 0 and num is 0 then the result is the empty string.
350
- fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str {
350
+ pure fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str {
351
351
ret if num < 0 {
352
352
~" -" + uint_to_str_prec(-num as uint, radix, prec)
353
353
} else { uint_to_str_prec(num as uint, radix, prec) };
@@ -356,7 +356,7 @@ mod rt {
356
356
// Convert a uint to string with a minimum number of digits. If precision
357
357
// is 0 and num is 0 then the result is the empty string. Could move this
358
358
// to uint: but it doesn't seem all that useful.
359
- fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str {
359
+ pure fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str {
360
360
ret if prec == 0u && num == 0u {
361
361
~" "
362
362
} else {
@@ -369,7 +369,7 @@ mod rt {
369
369
} else { s }
370
370
} ;
371
371
}
372
- fn get_int_precision ( cv : conv ) -> uint {
372
+ pure fn get_int_precision ( cv : conv ) -> uint {
373
373
ret alt cv. precision {
374
374
count_is ( c) { c as uint }
375
375
count_implied { 1 u }
0 commit comments