Skip to content

Commit 1303673

Browse files
committed
---
yaml --- r: 95205 b: refs/heads/dist-snap c: 50fde8c h: refs/heads/master i: 95203: a096701 v: v3
1 parent 8bb8290 commit 1303673

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
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: da145b237241345a9b14531d37f290082c4fb5f0
9+
refs/heads/dist-snap: 50fde8c024a30d01ed54a2d40eab7399bf1e7a3c
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)