@@ -353,29 +353,25 @@ pub trait ToPrimitive {
353
353
/// Converts the value of `self` to an `int`.
354
354
#[ inline]
355
355
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 ( ) )
358
357
}
359
358
360
359
/// Converts the value of `self` to an `i8`.
361
360
#[ inline]
362
361
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 ( ) )
365
363
}
366
364
367
365
/// Converts the value of `self` to an `i16`.
368
366
#[ inline]
369
367
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 ( ) )
372
369
}
373
370
374
371
/// Converts the value of `self` to an `i32`.
375
372
#[ inline]
376
373
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 ( ) )
379
375
}
380
376
381
377
/// Converts the value of `self` to an `i64`.
@@ -384,50 +380,43 @@ pub trait ToPrimitive {
384
380
/// Converts the value of `self` to an `uint`.
385
381
#[ inline]
386
382
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 ( ) )
389
384
}
390
385
391
386
/// Converts the value of `self` to an `u8`.
392
387
#[ inline]
393
388
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 ( ) )
396
390
}
397
391
398
392
/// Converts the value of `self` to an `u16`.
399
393
#[ inline]
400
394
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 ( ) )
403
396
}
404
397
405
398
/// Converts the value of `self` to an `u32`.
406
399
#[ inline]
407
400
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 ( ) )
410
402
}
411
403
412
404
/// Converts the value of `self` to an `u64`.
413
405
#[ inline]
414
406
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 ( ) )
417
408
}
418
409
419
410
/// Converts the value of `self` to an `f32`.
420
411
#[ inline]
421
412
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 ( ) )
424
414
}
425
415
426
416
/// Converts the value of `self` to an `f64`.
427
417
#[ inline]
428
418
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 ( ) )
431
420
}
432
421
}
433
422
0 commit comments