Skip to content

Commit 92051b4

Browse files
committed
---
yaml --- r: 82163 b: refs/heads/master c: 50fde8c h: refs/heads/master i: 82161: 40a1dfd 82159: b17a15a v: v3
1 parent 2fa51ec commit 92051b4

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: da145b237241345a9b14531d37f290082c4fb5f0
2+
refs/heads/master: 50fde8c024a30d01ed54a2d40eab7399bf1e7a3c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/libstd/num/num.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -353,29 +353,25 @@ pub trait ToPrimitive {
353353
/// Converts the value of `self` to an `int`.
354354
#[inline]
355355
fn to_int(&self) -> Option<int> {
356-
// XXX: Check for range.
357-
self.to_i64().and_then(|x| Some(x as int))
356+
self.to_i64().and_then(|x| x.to_int())
358357
}
359358

360359
/// Converts the value of `self` to an `i8`.
361360
#[inline]
362361
fn to_i8(&self) -> Option<i8> {
363-
// XXX: Check for range.
364-
self.to_i64().and_then(|x| Some(x as i8))
362+
self.to_i64().and_then(|x| x.to_i8())
365363
}
366364

367365
/// Converts the value of `self` to an `i16`.
368366
#[inline]
369367
fn to_i16(&self) -> Option<i16> {
370-
// XXX: Check for range.
371-
self.to_i64().and_then(|x| Some(x as i16))
368+
self.to_i64().and_then(|x| x.to_i16())
372369
}
373370

374371
/// Converts the value of `self` to an `i32`.
375372
#[inline]
376373
fn to_i32(&self) -> Option<i32> {
377-
// XXX: Check for range.
378-
self.to_i64().and_then(|x| Some(x as i32))
374+
self.to_i64().and_then(|x| x.to_i32())
379375
}
380376

381377
/// Converts the value of `self` to an `i64`.
@@ -384,50 +380,43 @@ pub trait ToPrimitive {
384380
/// Converts the value of `self` to an `uint`.
385381
#[inline]
386382
fn to_uint(&self) -> Option<uint> {
387-
// XXX: Check for range.
388-
self.to_u64().and_then(|x| Some(x as uint))
383+
self.to_u64().and_then(|x| x.to_uint())
389384
}
390385

391386
/// Converts the value of `self` to an `u8`.
392387
#[inline]
393388
fn to_u8(&self) -> Option<u8> {
394-
// XXX: Check for range.
395-
self.to_u64().and_then(|x| Some(x as u8))
389+
self.to_u64().and_then(|x| x.to_u8())
396390
}
397391

398392
/// Converts the value of `self` to an `u16`.
399393
#[inline]
400394
fn to_u16(&self) -> Option<u16> {
401-
// XXX: Check for range.
402-
self.to_u64().and_then(|x| Some(x as u16))
395+
self.to_u64().and_then(|x| x.to_u16())
403396
}
404397

405398
/// Converts the value of `self` to an `u32`.
406399
#[inline]
407400
fn to_u32(&self) -> Option<u32> {
408-
// XXX: Check for range.
409-
self.to_u64().and_then(|x| Some(x as u32))
401+
self.to_u64().and_then(|x| x.to_u32())
410402
}
411403

412404
/// Converts the value of `self` to an `u64`.
413405
#[inline]
414406
fn to_u64(&self) -> Option<u64> {
415-
// XXX: Check for range.
416-
self.to_u64().and_then(|x| Some(x as u64))
407+
self.to_u64().and_then(|x| x.to_u64())
417408
}
418409

419410
/// Converts the value of `self` to an `f32`.
420411
#[inline]
421412
fn to_f32(&self) -> Option<f32> {
422-
// XXX: Check for range.
423-
self.to_float().and_then(|x| Some(x as f32))
413+
self.to_f64().and_then(|x| x.to_f32())
424414
}
425415

426416
/// Converts the value of `self` to an `f64`.
427417
#[inline]
428418
fn to_f64(&self) -> Option<f64> {
429-
// XXX: Check for range.
430-
self.to_i64().and_then(|x| Some(x as f64))
419+
self.to_i64().and_then(|x| x.to_f64())
431420
}
432421
}
433422

0 commit comments

Comments
 (0)