Skip to content

Commit dc78fa6

Browse files
committed
---
yaml --- r: 46972 b: refs/heads/try c: adac6cb h: refs/heads/master v: v3
1 parent a92402a commit dc78fa6

23 files changed

+714
-638
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 20fd0c53edd2cc5ef5d413b8698b2c5860aa4926
5+
refs/heads/try: adac6cb5c61dfae79901264af4c235b66fb6267a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/num/f32.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use cmath;
1414
use cmp;
1515
use libc::{c_float, c_int};
1616
use num::NumCast;
17+
use num::strconv;
1718
use num;
1819
use ops;
1920
use option::Option;
@@ -376,8 +377,8 @@ impl num::Round for f32 {
376377
*/
377378
#[inline(always)]
378379
pub pure fn to_str(num: f32) -> ~str {
379-
let (r, _) = num::to_str_common(
380-
&num, 10u, true, true, num::SignNeg, num::DigAll);
380+
let (r, _) = strconv::to_str_common(
381+
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
381382
r
382383
}
383384

@@ -390,8 +391,8 @@ pub pure fn to_str(num: f32) -> ~str {
390391
*/
391392
#[inline(always)]
392393
pub pure fn to_str_hex(num: f32) -> ~str {
393-
let (r, _) = num::to_str_common(
394-
&num, 16u, true, true, num::SignNeg, num::DigAll);
394+
let (r, _) = strconv::to_str_common(
395+
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
395396
r
396397
}
397398

@@ -411,8 +412,8 @@ pub pure fn to_str_hex(num: f32) -> ~str {
411412
*/
412413
#[inline(always)]
413414
pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str {
414-
let (r, special) = num::to_str_common(
415-
&num, rdx, true, true, num::SignNeg, num::DigAll);
415+
let (r, special) = strconv::to_str_common(
416+
&num, rdx, true, true, strconv::SignNeg, strconv::DigAll);
416417
if special { fail!(~"number has a special value, \
417418
try to_str_radix_special() if those are expected") }
418419
r
@@ -429,7 +430,8 @@ pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str {
429430
*/
430431
#[inline(always)]
431432
pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
432-
num::to_str_common(&num, rdx, true, true, num::SignNeg, num::DigAll)
433+
strconv::to_str_common(&num, rdx, true, true,
434+
strconv::SignNeg, strconv::DigAll)
433435
}
434436

435437
/**
@@ -443,8 +445,8 @@ pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
443445
*/
444446
#[inline(always)]
445447
pub pure fn to_str_exact(num: f32, dig: uint) -> ~str {
446-
let (r, _) = num::to_str_common(
447-
&num, 10u, true, true, num::SignNeg, num::DigExact(dig));
448+
let (r, _) = strconv::to_str_common(
449+
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(dig));
448450
r
449451
}
450452

@@ -459,8 +461,8 @@ pub pure fn to_str_exact(num: f32, dig: uint) -> ~str {
459461
*/
460462
#[inline(always)]
461463
pub pure fn to_str_digits(num: f32, dig: uint) -> ~str {
462-
let (r, _) = num::to_str_common(
463-
&num, 10u, true, true, num::SignNeg, num::DigMax(dig));
464+
let (r, _) = strconv::to_str_common(
465+
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(dig));
464466
r
465467
}
466468

@@ -505,7 +507,8 @@ impl num::ToStrRadix for f32 {
505507
*/
506508
#[inline(always)]
507509
pub pure fn from_str(num: &str) -> Option<f32> {
508-
num::from_str_common(num, 10u, true, true, true, num::ExpDec, false)
510+
strconv::from_str_common(num, 10u, true, true, true,
511+
strconv::ExpDec, false)
509512
}
510513

511514
/**
@@ -537,7 +540,8 @@ pub pure fn from_str(num: &str) -> Option<f32> {
537540
*/
538541
#[inline(always)]
539542
pub pure fn from_str_hex(num: &str) -> Option<f32> {
540-
num::from_str_common(num, 16u, true, true, true, num::ExpBin, false)
543+
strconv::from_str_common(num, 16u, true, true, true,
544+
strconv::ExpBin, false)
541545
}
542546

543547
/**
@@ -561,7 +565,8 @@ pub pure fn from_str_hex(num: &str) -> Option<f32> {
561565
*/
562566
#[inline(always)]
563567
pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
564-
num::from_str_common(num, rdx, true, true, false, num::ExpNone, false)
568+
strconv::from_str_common(num, rdx, true, true, false,
569+
strconv::ExpNone, false)
565570
}
566571

567572
impl from_str::FromStr for f32 {

branches/try/src/libcore/num/f64.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use cmp;
1515
use libc::{c_double, c_int};
1616
use libc;
1717
use num::NumCast;
18+
use num::strconv;
1819
use num;
1920
use ops;
2021
use option::Option;
@@ -401,8 +402,8 @@ impl num::Round for f64 {
401402
*/
402403
#[inline(always)]
403404
pub pure fn to_str(num: f64) -> ~str {
404-
let (r, _) = num::to_str_common(
405-
&num, 10u, true, true, num::SignNeg, num::DigAll);
405+
let (r, _) = strconv::to_str_common(
406+
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
406407
r
407408
}
408409

@@ -415,8 +416,8 @@ pub pure fn to_str(num: f64) -> ~str {
415416
*/
416417
#[inline(always)]
417418
pub pure fn to_str_hex(num: f64) -> ~str {
418-
let (r, _) = num::to_str_common(
419-
&num, 16u, true, true, num::SignNeg, num::DigAll);
419+
let (r, _) = strconv::to_str_common(
420+
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
420421
r
421422
}
422423

@@ -436,8 +437,8 @@ pub pure fn to_str_hex(num: f64) -> ~str {
436437
*/
437438
#[inline(always)]
438439
pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str {
439-
let (r, special) = num::to_str_common(
440-
&num, rdx, true, true, num::SignNeg, num::DigAll);
440+
let (r, special) = strconv::to_str_common(
441+
&num, rdx, true, true, strconv::SignNeg, strconv::DigAll);
441442
if special { fail!(~"number has a special value, \
442443
try to_str_radix_special() if those are expected") }
443444
r
@@ -454,7 +455,8 @@ pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str {
454455
*/
455456
#[inline(always)]
456457
pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
457-
num::to_str_common(&num, rdx, true, true, num::SignNeg, num::DigAll)
458+
strconv::to_str_common(&num, rdx, true, true,
459+
strconv::SignNeg, strconv::DigAll)
458460
}
459461

460462
/**
@@ -468,8 +470,8 @@ pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
468470
*/
469471
#[inline(always)]
470472
pub pure fn to_str_exact(num: f64, dig: uint) -> ~str {
471-
let (r, _) = num::to_str_common(
472-
&num, 10u, true, true, num::SignNeg, num::DigExact(dig));
473+
let (r, _) = strconv::to_str_common(
474+
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(dig));
473475
r
474476
}
475477

@@ -484,8 +486,8 @@ pub pure fn to_str_exact(num: f64, dig: uint) -> ~str {
484486
*/
485487
#[inline(always)]
486488
pub pure fn to_str_digits(num: f64, dig: uint) -> ~str {
487-
let (r, _) = num::to_str_common(
488-
&num, 10u, true, true, num::SignNeg, num::DigMax(dig));
489+
let (r, _) = strconv::to_str_common(
490+
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(dig));
489491
r
490492
}
491493

@@ -530,7 +532,8 @@ impl num::ToStrRadix for f64 {
530532
*/
531533
#[inline(always)]
532534
pub pure fn from_str(num: &str) -> Option<f64> {
533-
num::from_str_common(num, 10u, true, true, true, num::ExpDec, false)
535+
strconv::from_str_common(num, 10u, true, true, true,
536+
strconv::ExpDec, false)
534537
}
535538

536539
/**
@@ -562,7 +565,8 @@ pub pure fn from_str(num: &str) -> Option<f64> {
562565
*/
563566
#[inline(always)]
564567
pub pure fn from_str_hex(num: &str) -> Option<f64> {
565-
num::from_str_common(num, 16u, true, true, true, num::ExpBin, false)
568+
strconv::from_str_common(num, 16u, true, true, true,
569+
strconv::ExpBin, false)
566570
}
567571

568572
/**
@@ -586,7 +590,8 @@ pub pure fn from_str_hex(num: &str) -> Option<f64> {
586590
*/
587591
#[inline(always)]
588592
pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
589-
num::from_str_common(num, rdx, true, true, false, num::ExpNone, false)
593+
strconv::from_str_common(num, rdx, true, true, false,
594+
strconv::ExpNone, false)
590595
}
591596

592597
impl from_str::FromStr for f64 {

branches/try/src/libcore/num/float.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use cmp::{Eq, Ord};
2626
use cmp;
2727
use f64;
2828
use num::NumCast;
29+
use num::strconv;
2930
use num;
3031
use ops;
3132
use option::{None, Option, Some};
@@ -107,8 +108,8 @@ pub mod consts {
107108
*/
108109
#[inline(always)]
109110
pub pure fn to_str(num: float) -> ~str {
110-
let (r, _) = num::to_str_common(
111-
&num, 10u, true, true, num::SignNeg, num::DigAll);
111+
let (r, _) = strconv::to_str_common(
112+
&num, 10u, true, true, strconv::SignNeg, strconv::DigAll);
112113
r
113114
}
114115

@@ -121,8 +122,8 @@ pub pure fn to_str(num: float) -> ~str {
121122
*/
122123
#[inline(always)]
123124
pub pure fn to_str_hex(num: float) -> ~str {
124-
let (r, _) = num::to_str_common(
125-
&num, 16u, true, true, num::SignNeg, num::DigAll);
125+
let (r, _) = strconv::to_str_common(
126+
&num, 16u, true, true, strconv::SignNeg, strconv::DigAll);
126127
r
127128
}
128129

@@ -142,8 +143,8 @@ pub pure fn to_str_hex(num: float) -> ~str {
142143
*/
143144
#[inline(always)]
144145
pub pure fn to_str_radix(num: float, radix: uint) -> ~str {
145-
let (r, special) = num::to_str_common(
146-
&num, radix, true, true, num::SignNeg, num::DigAll);
146+
let (r, special) = strconv::to_str_common(
147+
&num, radix, true, true, strconv::SignNeg, strconv::DigAll);
147148
if special { fail!(~"number has a special value, \
148149
try to_str_radix_special() if those are expected") }
149150
r
@@ -160,7 +161,8 @@ pub pure fn to_str_radix(num: float, radix: uint) -> ~str {
160161
*/
161162
#[inline(always)]
162163
pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
163-
num::to_str_common(&num, radix, true, true, num::SignNeg, num::DigAll)
164+
strconv::to_str_common(&num, radix, true, true,
165+
strconv::SignNeg, strconv::DigAll)
164166
}
165167
166168
/**
@@ -174,8 +176,8 @@ pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
174176
*/
175177
#[inline(always)]
176178
pub pure fn to_str_exact(num: float, digits: uint) -> ~str {
177-
let (r, _) = num::to_str_common(
178-
&num, 10u, true, true, num::SignNeg, num::DigExact(digits));
179+
let (r, _) = strconv::to_str_common(
180+
&num, 10u, true, true, strconv::SignNeg, strconv::DigExact(digits));
179181
r
180182
}
181183
@@ -196,8 +198,8 @@ pub fn test_to_str_exact_do_decimal() {
196198
*/
197199
#[inline(always)]
198200
pub pure fn to_str_digits(num: float, digits: uint) -> ~str {
199-
let (r, _) = num::to_str_common(
200-
&num, 10u, true, true, num::SignNeg, num::DigMax(digits));
201+
let (r, _) = strconv::to_str_common(
202+
&num, 10u, true, true, strconv::SignNeg, strconv::DigMax(digits));
201203
r
202204
}
203205
@@ -242,7 +244,8 @@ impl num::ToStrRadix for float {
242244
*/
243245
#[inline(always)]
244246
pub pure fn from_str(num: &str) -> Option<float> {
245-
num::from_str_common(num, 10u, true, true, true, num::ExpDec, false)
247+
strconv::from_str_common(num, 10u, true, true, true,
248+
strconv::ExpDec, false)
246249
}
247250
248251
/**
@@ -274,7 +277,8 @@ pub pure fn from_str(num: &str) -> Option<float> {
274277
*/
275278
#[inline(always)]
276279
pub pure fn from_str_hex(num: &str) -> Option<float> {
277-
num::from_str_common(num, 16u, true, true, true, num::ExpBin, false)
280+
strconv::from_str_common(num, 16u, true, true, true,
281+
strconv::ExpBin, false)
278282
}
279283
280284
/**
@@ -298,7 +302,8 @@ pub pure fn from_str_hex(num: &str) -> Option<float> {
298302
*/
299303
#[inline(always)]
300304
pub pure fn from_str_radix(num: &str, radix: uint) -> Option<float> {
301-
num::from_str_common(num, radix, true, true, false, num::ExpNone, false)
305+
strconv::from_str_common(num, radix, true, true, false,
306+
strconv::ExpNone, false)
302307
}
303308
304309
impl from_str::FromStr for float {

branches/try/src/libcore/num/int-template.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use cmp;
1616
use to_str::ToStr;
1717
use from_str::FromStr;
1818
use num::{ToStrRadix, FromStrRadix};
19+
use num::strconv;
1920
use num;
2021
use prelude::*;
2122
use str;
@@ -218,22 +219,22 @@ impl ops::Neg<T> for T {
218219
/// Parse a string as a number in base 10.
219220
#[inline(always)]
220221
pub pure fn from_str(s: &str) -> Option<T> {
221-
num::from_str_common(s, 10u, true, false, false,
222-
num::ExpNone, false)
222+
strconv::from_str_common(s, 10u, true, false, false,
223+
strconv::ExpNone, false)
223224
}
224225
225226
/// Parse a string as a number in the given base.
226227
#[inline(always)]
227228
pub pure fn from_str_radix(s: &str, radix: uint) -> Option<T> {
228-
num::from_str_common(s, radix, true, false, false,
229-
num::ExpNone, false)
229+
strconv::from_str_common(s, radix, true, false, false,
230+
strconv::ExpNone, false)
230231
}
231232
232233
/// Parse a byte slice as a number in the given base.
233234
#[inline(always)]
234235
pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
235-
num::from_str_bytes_common(buf, radix, true, false, false,
236-
num::ExpNone, false)
236+
strconv::from_str_bytes_common(buf, radix, true, false, false,
237+
strconv::ExpNone, false)
237238
}
238239
239240
impl FromStr for T {
@@ -255,24 +256,24 @@ impl FromStrRadix for T {
255256
/// Convert to a string as a byte slice in a given base.
256257
#[inline(always)]
257258
pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U {
258-
let (buf, _) = num::to_str_bytes_common(&n, radix, false, false,
259-
num::SignNeg, num::DigAll);
259+
let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, false,
260+
strconv::SignNeg, strconv::DigAll);
260261
f(buf)
261262
}
262263
263264
/// Convert to a string in base 10.
264265
#[inline(always)]
265266
pub pure fn to_str(num: T) -> ~str {
266-
let (buf, _) = num::to_str_common(&num, 10u, false, false,
267-
num::SignNeg, num::DigAll);
267+
let (buf, _) = strconv::to_str_common(&num, 10u, false, false,
268+
strconv::SignNeg, strconv::DigAll);
268269
buf
269270
}
270271
271272
/// Convert to a string in a given base.
272273
#[inline(always)]
273274
pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
274-
let (buf, _) = num::to_str_common(&num, radix, false, false,
275-
num::SignNeg, num::DigAll);
275+
let (buf, _) = strconv::to_str_common(&num, radix, false, false,
276+
strconv::SignNeg, strconv::DigAll);
276277
buf
277278
}
278279

0 commit comments

Comments
 (0)