1
Fork 0

std: add Primitive.is_signed

This commit is contained in:
Erick Tryzelaar 2013-09-27 20:41:49 -07:00
parent 50fde8c024
commit 41f9deb2ee
5 changed files with 13 additions and 0 deletions

View file

@ -590,6 +590,9 @@ impl Primitive for f32 {
#[inline]
fn bytes(_: Option<f32>) -> uint { Primitive::bits(Some(0f32)) / 8 }
#[inline]
fn is_signed(_: Option<f32>) -> bool { true }
}
impl Float for f32 {

View file

@ -638,6 +638,9 @@ impl Primitive for f64 {
#[inline]
fn bytes(_: Option<f64>) -> uint { Primitive::bits(Some(0f64)) / 8 }
#[inline]
fn is_signed(_: Option<f64>) -> bool { true }
}
impl Float for f64 {

View file

@ -380,6 +380,9 @@ impl Primitive for $T {
#[inline]
fn bytes(_: Option<$T>) -> uint { bits / 8 }
#[inline]
fn is_signed(_: Option<$T>) -> bool { true }
}
// String conversion functions and impl str -> num

View file

@ -286,6 +286,7 @@ pub trait Primitive: Clone
// FIXME (#8888): Removing `unused_self` requires #8888 to be fixed.
fn bits(unused_self: Option<Self>) -> uint;
fn bytes(unused_self: Option<Self>) -> uint;
fn is_signed(unused_self: Option<Self>) -> bool;
}
/// A collection of traits relevant to primitive signed and unsigned integers

View file

@ -306,6 +306,9 @@ impl Primitive for $T {
#[inline]
fn bytes(_: Option<$T>) -> uint { bits / 8 }
#[inline]
fn is_signed(_: Option<$T>) -> bool { false }
}
impl BitCount for $T {