Skip to content

Commit bd93a36

Browse files
committed
Made num <-> str conversion functions use NumStrConv trait
Removed hacky dependency on Round trait and generic infinity functions Removed generic-runtime-failure-depending-on-type behavior
1 parent 26e0aaf commit bd93a36

File tree

6 files changed

+111
-119
lines changed

6 files changed

+111
-119
lines changed

src/libcore/num/f32.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl num::Round for f32 {
378378
#[inline(always)]
379379
pub pure fn to_str(num: f32) -> ~str {
380380
let (r, _) = strconv::to_str_common(
381-
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
381+
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
382382
r
383383
}
384384

@@ -392,7 +392,7 @@ pub pure fn to_str(num: f32) -> ~str {
392392
#[inline(always)]
393393
pub pure fn to_str_hex(num: f32) -> ~str {
394394
let (r, _) = strconv::to_str_common(
395-
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
395+
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
396396
r
397397
}
398398

@@ -413,7 +413,7 @@ pub pure fn to_str_hex(num: f32) -> ~str {
413413
#[inline(always)]
414414
pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str {
415415
let (r, special) = strconv::to_str_common(
416-
&num, rdx, true, true, strconv::SignNeg, strconv::DigAll);
416+
&num, rdx, true, strconv::SignNeg, strconv::DigAll);
417417
if special { fail!(~"number has a special value, \
418418
try to_str_radix_special() if those are expected") }
419419
r
@@ -430,7 +430,7 @@ pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str {
430430
*/
431431
#[inline(always)]
432432
pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
433-
strconv::to_str_common(&num, rdx, true, true,
433+
strconv::to_str_common(&num, rdx, true,
434434
strconv::SignNeg, strconv::DigAll)
435435
}
436436

@@ -446,7 +446,7 @@ pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
446446
#[inline(always)]
447447
pub pure fn to_str_exact(num: f32, dig: uint) -> ~str {
448448
let (r, _) = strconv::to_str_common(
449-
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(dig));
449+
&num, 10u, true, strconv::SignNeg, strconv::DigExact(dig));
450450
r
451451
}
452452

@@ -462,7 +462,7 @@ pub pure fn to_str_exact(num: f32, dig: uint) -> ~str {
462462
#[inline(always)]
463463
pub pure fn to_str_digits(num: f32, dig: uint) -> ~str {
464464
let (r, _) = strconv::to_str_common(
465-
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(dig));
465+
&num, 10u, true, strconv::SignNeg, strconv::DigMax(dig));
466466
r
467467
}
468468

src/libcore/num/f64.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ impl num::Round for f64 {
403403
#[inline(always)]
404404
pub pure fn to_str(num: f64) -> ~str {
405405
let (r, _) = strconv::to_str_common(
406-
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
406+
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
407407
r
408408
}
409409

@@ -417,7 +417,7 @@ pub pure fn to_str(num: f64) -> ~str {
417417
#[inline(always)]
418418
pub pure fn to_str_hex(num: f64) -> ~str {
419419
let (r, _) = strconv::to_str_common(
420-
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
420+
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
421421
r
422422
}
423423

@@ -438,7 +438,7 @@ pub pure fn to_str_hex(num: f64) -> ~str {
438438
#[inline(always)]
439439
pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str {
440440
let (r, special) = strconv::to_str_common(
441-
&num, rdx, true, true, strconv::SignNeg, strconv::DigAll);
441+
&num, rdx, true, strconv::SignNeg, strconv::DigAll);
442442
if special { fail!(~"number has a special value, \
443443
try to_str_radix_special() if those are expected") }
444444
r
@@ -455,7 +455,7 @@ pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str {
455455
*/
456456
#[inline(always)]
457457
pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
458-
strconv::to_str_common(&num, rdx, true, true,
458+
strconv::to_str_common(&num, rdx, true,
459459
strconv::SignNeg, strconv::DigAll)
460460
}
461461

@@ -471,7 +471,7 @@ pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
471471
#[inline(always)]
472472
pub pure fn to_str_exact(num: f64, dig: uint) -> ~str {
473473
let (r, _) = strconv::to_str_common(
474-
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(dig));
474+
&num, 10u, true, strconv::SignNeg, strconv::DigExact(dig));
475475
r
476476
}
477477

@@ -487,7 +487,7 @@ pub pure fn to_str_exact(num: f64, dig: uint) -> ~str {
487487
#[inline(always)]
488488
pub pure fn to_str_digits(num: f64, dig: uint) -> ~str {
489489
let (r, _) = strconv::to_str_common(
490-
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(dig));
490+
&num, 10u, true, strconv::SignNeg, strconv::DigMax(dig));
491491
r
492492
}
493493

src/libcore/num/float.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub mod consts {
109109
#[inline(always)]
110110
pub pure fn to_str(num: float) -> ~str {
111111
let (r, _) = strconv::to_str_common(
112-
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
112+
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
113113
r
114114
}
115115

@@ -123,7 +123,7 @@ pub pure fn to_str(num: float) -> ~str {
123123
#[inline(always)]
124124
pub pure fn to_str_hex(num: float) -> ~str {
125125
let (r, _) = strconv::to_str_common(
126-
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
126+
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
127127
r
128128
}
129129

@@ -144,7 +144,7 @@ pub pure fn to_str_hex(num: float) -> ~str {
144144
#[inline(always)]
145145
pub pure fn to_str_radix(num: float, radix: uint) -> ~str {
146146
let (r, special) = strconv::to_str_common(
147-
&num, radix, true, true, strconv::SignNeg, strconv::DigAll);
147+
&num, radix, true, strconv::SignNeg, strconv::DigAll);
148148
if special { fail!(~"number has a special value, \
149149
try to_str_radix_special() if those are expected") }
150150
r
@@ -161,7 +161,7 @@ pub pure fn to_str_radix(num: float, radix: uint) -> ~str {
161161
*/
162162
#[inline(always)]
163163
pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
164-
strconv::to_str_common(&num, radix, true, true,
164+
strconv::to_str_common(&num, radix, true,
165165
strconv::SignNeg, strconv::DigAll)
166166
}
167167
@@ -177,7 +177,7 @@ pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
177177
#[inline(always)]
178178
pub pure fn to_str_exact(num: float, digits: uint) -> ~str {
179179
let (r, _) = strconv::to_str_common(
180-
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(digits));
180+
&num, 10u, true, strconv::SignNeg, strconv::DigExact(digits));
181181
r
182182
}
183183
@@ -199,7 +199,7 @@ pub fn test_to_str_exact_do_decimal() {
199199
#[inline(always)]
200200
pub pure fn to_str_digits(num: float, digits: uint) -> ~str {
201201
let (r, _) = strconv::to_str_common(
202-
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(digits));
202+
&num, 10u, true, strconv::SignNeg, strconv::DigMax(digits));
203203
r
204204
}
205205

src/libcore/num/int-template.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,23 @@ impl FromStrRadix for T {
256256
/// Convert to a string as a byte slice in a given base.
257257
#[inline(always)]
258258
pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U {
259-
let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, false,
259+
let (buf, _) = strconv::to_str_bytes_common(&n, radix, false,
260260
strconv::SignNeg, strconv::DigAll);
261261
f(buf)
262262
}
263263
264264
/// Convert to a string in base 10.
265265
#[inline(always)]
266266
pub pure fn to_str(num: T) -> ~str {
267-
let (buf, _) = strconv::to_str_common(&num, 10u, false, false,
267+
let (buf, _) = strconv::to_str_common(&num, 10u, false,
268268
strconv::SignNeg, strconv::DigAll);
269269
buf
270270
}
271271
272272
/// Convert to a string in a given base.
273273
#[inline(always)]
274274
pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
275-
let (buf, _) = strconv::to_str_common(&num, radix, false, false,
275+
let (buf, _) = strconv::to_str_common(&num, radix, false,
276276
strconv::SignNeg, strconv::DigAll);
277277
buf
278278
}

0 commit comments

Comments
 (0)